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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 12, 2014 at 15:33 UTC
852e54bc0f8c7a478bf1f3a13b45fdfc6604aba7
1 file changed
+12
-12
transport-helper.c
+12
-12
@@ -195,15 +195,9 @@ static struct child_process *get_helper(struct transport *transport)
195
} else if (!strcmp(capname, "signed-tags")) {
196
data->signed_tags = 1;
197
} 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 "));
199
} 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 "));
201
} else if (starts_with(capname, "no-private-update")) {
202
data->no_private_update = 1;
203
} else if (mandatory) {
@@ -428,6 +422,8 @@ static int get_exporter(struct transport *transport,
422
struct helper_data *data = transport->data;
423
struct child_process *helper = get_helper(transport);
424
int argc = 0, i;
425
+ struct strbuf tmp = STRBUF_INIT;
426
+
427
memset(fastexport, 0, sizeof(*fastexport));
428
429
/* we need to duplicate helper->in because we want to use it after
@@ -438,10 +434,14 @@ static int get_exporter(struct transport *transport,
434
fastexport->argv[argc++] = "--use-done-feature";
435
fastexport->argv[argc++] = data->signed_tags ?
436
"--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
+ }
445
446
for (i = 0; i < revlist_args->nr; i++)
447
fastexport->argv[argc++] = revlist_args->items[i].string;