Skip to content

Commit

Permalink
get_importer: use run-command's internal argv_array
Browse files Browse the repository at this point in the history
This saves a few lines and lets us avoid having to clean up
the memory manually when the command finishes.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 15, 2014
1 parent 2aeae40 commit 173fd1a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,16 @@ static int get_importer(struct transport *transport, struct child_process *fasti
{
struct child_process *helper = get_helper(transport);
struct helper_data *data = transport->data;
struct argv_array argv = ARGV_ARRAY_INIT;
int cat_blob_fd, code;
memset(fastimport, 0, sizeof(*fastimport));
fastimport->in = helper->out;
argv_array_push(&argv, "fast-import");
argv_array_push(&argv, debug ? "--stats" : "--quiet");
argv_array_push(&fastimport->args, "fast-import");
argv_array_push(&fastimport->args, debug ? "--stats" : "--quiet");

if (data->bidi_import) {
cat_blob_fd = xdup(helper->in);
argv_array_pushf(&argv, "--cat-blob-fd=%d", cat_blob_fd);
argv_array_pushf(&fastimport->args, "--cat-blob-fd=%d", cat_blob_fd);
}
fastimport->argv = argv.argv;
fastimport->git_cmd = 1;

code = start_command(fastimport);
Expand Down Expand Up @@ -476,7 +474,6 @@ static int fetch_with_import(struct transport *transport,

if (finish_command(&fastimport))
die("Error while running fast-import");
argv_array_free_detached(fastimport.argv);

/*
* The fast-import stream of a remote helper that advertises
Expand Down

0 comments on commit 173fd1a

Please sign in to comment.