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>

Jeff King committed Jun 24, 2014 at 05:46 UTC 36857e0026f5a7855f941a955bf7014408a816dd
1 file changed +5 -3
builtin/replace.c
+5 -3
@@ -193,15 +193,17 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
193 */
194 static void export_object(const unsigned char *sha1, const char *filename)
195 {
196 - const char *argv[] = { "--no-replace-objects", "cat-file", "-p", NULL, NULL };
197 - struct child_process cmd = { argv };
196 + struct child_process cmd = { NULL };
197 int fd;
198
199 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
200 if (fd < 0)
201 die_errno("unable to open %s for writing", filename);
202
204 - argv[3] = sha1_to_hex(sha1);
203 + argv_array_push(&cmd.args, "--no-replace-objects");
204 + argv_array_push(&cmd.args, "cat-file");
205 + argv_array_push(&cmd.args, "-p");
206 + argv_array_push(&cmd.args, sha1_to_hex(sha1));
207 cmd.git_cmd = 1;
208 cmd.out = fd;
209