X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=merge-index.c;h=19ddd03e0b2a57d03d85b1e5ca73b0bd4a0d6981;hb=529f8c6ea6c13d85178d4ed10ed60ed8fd6f6c19;hp=7827e87a928586226570132fc8922991b1cb6c8a;hpb=a1eb73d917e15cd97314e0a39cbe857329339a96;p=git.git diff --git a/merge-index.c b/merge-index.c index 7827e87a9..19ddd03e0 100644 --- a/merge-index.c +++ b/merge-index.c @@ -1,46 +1,22 @@ #include "cache.h" #include "run-command.h" +#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); @@ -54,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; } @@ -91,7 +76,9 @@ int main(int argc, char **argv) signal(SIGCHLD, SIG_DFL); if (argc < 3) - usage("git-merge-index [-o] [-q] (-a | [--] *)"); + usage("git merge-index [-o] [-q] (-a | [--] *)"); + + git_extract_argv0_path(argv[0]); setup_git_directory(); read_cache();