Skip to content

Commit 852e54b

Browse files
felipecgitster
authored andcommitted
transport-helper: trivial cleanup
It's simpler to store the file names directly, and form the fast-export arguments only when needed, and re-use the same strbuf with a format. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0551a06 commit 852e54b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

transport-helper.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,9 @@ static struct child_process *get_helper(struct transport *transport)
195195
} else if (!strcmp(capname, "signed-tags")) {
196196
data->signed_tags = 1;
197197
} else if (starts_with(capname, "export-marks ")) {
198-
struct strbuf arg = STRBUF_INIT;
199-
strbuf_addstr(&arg, "--export-marks=");
200-
strbuf_addstr(&arg, capname + strlen("export-marks "));
201-
data->export_marks = strbuf_detach(&arg, NULL);
198+
data->export_marks = xstrdup(capname + strlen("export-marks "));
202199
} else if (starts_with(capname, "import-marks")) {
203-
struct strbuf arg = STRBUF_INIT;
204-
strbuf_addstr(&arg, "--import-marks=");
205-
strbuf_addstr(&arg, capname + strlen("import-marks "));
206-
data->import_marks = strbuf_detach(&arg, NULL);
200+
data->import_marks = xstrdup(capname + strlen("import-marks "));
207201
} else if (starts_with(capname, "no-private-update")) {
208202
data->no_private_update = 1;
209203
} else if (mandatory) {
@@ -428,6 +422,8 @@ static int get_exporter(struct transport *transport,
428422
struct helper_data *data = transport->data;
429423
struct child_process *helper = get_helper(transport);
430424
int argc = 0, i;
425+
struct strbuf tmp = STRBUF_INIT;
426+
431427
memset(fastexport, 0, sizeof(*fastexport));
432428

433429
/* we need to duplicate helper->in because we want to use it after
@@ -438,10 +434,14 @@ static int get_exporter(struct transport *transport,
438434
fastexport->argv[argc++] = "--use-done-feature";
439435
fastexport->argv[argc++] = data->signed_tags ?
440436
"--signed-tags=verbatim" : "--signed-tags=warn-strip";
441-
if (data->export_marks)
442-
fastexport->argv[argc++] = data->export_marks;
443-
if (data->import_marks)
444-
fastexport->argv[argc++] = data->import_marks;
437+
if (data->export_marks) {
438+
strbuf_addf(&tmp, "--export-marks=%s", data->export_marks);
439+
fastexport->argv[argc++] = strbuf_detach(&tmp, NULL);
440+
}
441+
if (data->import_marks) {
442+
strbuf_addf(&tmp, "--import-marks=%s", data->import_marks);
443+
fastexport->argv[argc++] = strbuf_detach(&tmp, NULL);
444+
}
445445

446446
for (i = 0; i < revlist_args->nr; i++)
447447
fastexport->argv[argc++] = revlist_args->items[i].string;

0 commit comments

Comments
 (0)