]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Simplify some instances of run_command() by using run_command_v_opt().
authorJohannes Sixt <j6t@kdbg.org>
Mon, 8 Jun 2009 20:34:29 +0000 (22:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Jun 2009 07:15:57 +0000 (00:15 -0700)
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-receive-pack.c
ll-merge.c
merge-index.c

index 0b08da9b595432efa231eb59d88ecd2b422eb56a..33d345dc3993d01d3cd5ae1cc0aa5ae8eda83edb 100644 (file)
@@ -192,7 +192,6 @@ static int run_receive_hook(const char *hook_name)
 static int run_update_hook(struct command *cmd)
 {
        static const char update_hook[] = "hooks/update";
-       struct child_process proc;
        const char *argv[5];
 
        if (access(update_hook, X_OK) < 0)
@@ -204,12 +203,9 @@ static int run_update_hook(struct command *cmd)
        argv[3] = sha1_to_hex(cmd->new_sha1);
        argv[4] = NULL;
 
-       memset(&proc, 0, sizeof(proc));
-       proc.argv = argv;
-       proc.no_stdin = 1;
-       proc.stdout_to_stderr = 1;
-
-       return hook_status(run_command(&proc), update_hook);
+       return hook_status(run_command_v_opt(argv, RUN_COMMAND_NO_STDIN |
+                                       RUN_COMMAND_STDOUT_TO_STDERR),
+                       update_hook);
 }
 
 static int is_ref_checked_out(const char *ref)
index 81c02ad0531e98379d8cd11dc7c2d70214d67fb4..31d6f0a2ee63e8c3cad1053f9281a0ce9917fb32 100644 (file)
@@ -175,8 +175,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
                { "B", temp[2] },
                { NULL }
        };
-       struct child_process child;
-       const char *args[20];
+       const char *args[] = { "sh", "-c", NULL, NULL };
        int status, fd, i;
        struct stat st;
 
@@ -191,14 +190,8 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
 
        strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
 
-       memset(&child, 0, sizeof(child));
-       child.argv = args;
-       args[0] = "sh";
-       args[1] = "-c";
        args[2] = cmd.buf;
-       args[3] = NULL;
-
-       status = run_command(&child);
+       status = run_command_v_opt(args, 0);
        if (status < -ERR_RUN_COMMAND_FORK)
                ; /* failure in run-command */
        else
index aa9cf23a39ae271a53d1a0c05ac99be0e832b46a..19ddd03e0b2a57d03d85b1e5ca73b0bd4a0d6981 100644 (file)
@@ -3,45 +3,20 @@
 #include "exec_cmd.h"
 
 static const char *pgm;
-static const char *arguments[9];
 static int one_shot, quiet;
 static int err;
 
-static void run_program(void)
-{
-       struct child_process child;
-       memset(&child, 0, sizeof(child));
-       child.argv = arguments;
-       if (run_command(&child)) {
-               if (one_shot) {
-                       err++;
-               } else {
-                       if (!quiet)
-                               die("merge program failed");
-                       exit(1);
-               }
-       }
-}
-
 static int merge_entry(int pos, const char *path)
 {
        int found;
+       const char *arguments[] = { pgm, "", "", "", path, "", "", "", NULL };
+       char hexbuf[4][60];
+       char ownbuf[4][60];
 
        if (pos >= active_nr)
                die("git merge-index: %s not in the cache", path);
-       arguments[0] = pgm;
-       arguments[1] = "";
-       arguments[2] = "";
-       arguments[3] = "";
-       arguments[4] = path;
-       arguments[5] = "";
-       arguments[6] = "";
-       arguments[7] = "";
-       arguments[8] = NULL;
        found = 0;
        do {
-               static char hexbuf[4][60];
-               static char ownbuf[4][60];
                struct cache_entry *ce = active_cache[pos];
                int stage = ce_stage(ce);
 
@@ -55,7 +30,16 @@ static int merge_entry(int pos, const char *path)
        } while (++pos < active_nr);
        if (!found)
                die("git merge-index: %s not in the cache", path);
-       run_program();
+
+       if (run_command_v_opt(arguments, 0)) {
+               if (one_shot)
+                       err++;
+               else {
+                       if (!quiet)
+                               die("merge program failed");
+                       exit(1);
+               }
+       }
        return found;
 }