summaryrefslogtreecommitdiff
path: root/builtin/replace.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-06-24 09:46:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-25 22:28:01 (GMT)
commit36857e0026f5a7855f941a955bf7014408a816dd (patch)
tree1f7863592d5289460a4888341497cb2baaecd45f /builtin/replace.c
parent28bf9429ef2e1534be8d3a59ad236834be542b86 (diff)
downloadgit-36857e0026f5a7855f941a955bf7014408a816dd.zip
git-36857e0026f5a7855f941a955bf7014408a816dd.tar.gz
git-36857e0026f5a7855f941a955bf7014408a816dd.tar.bz2
replace: use argv_array in export_object
This is a little more verbose, but will make it easier to make parts of our command-line conditional (without resorting to magic numbers or lots of NULLs to get an appropriately sized argv array). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/replace.c')
-rw-r--r--builtin/replace.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/builtin/replace.c b/builtin/replace.c
index eb1d2ec..2584170 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -193,15 +193,17 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
*/
static void export_object(const unsigned char *sha1, const char *filename)
{
- const char *argv[] = { "--no-replace-objects", "cat-file", "-p", NULL, NULL };
- struct child_process cmd = { argv };
+ struct child_process cmd = { NULL };
int fd;
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
die_errno("unable to open %s for writing", filename);
- argv[3] = sha1_to_hex(sha1);
+ argv_array_push(&cmd.args, "--no-replace-objects");
+ argv_array_push(&cmd.args, "cat-file");
+ argv_array_push(&cmd.args, "-p");
+ argv_array_push(&cmd.args, sha1_to_hex(sha1));
cmd.git_cmd = 1;
cmd.out = fd;