X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=merge-index.c;h=5599fd321bb4c09c1c0ce4fc62dfb9ecf5531c2b;hb=d01fb92f8d27cf8f0a843f4e9c0f8f022856b34d;hp=190e12fb7ceeb012a063f8c97b574e9650d95cc1;hpb=c3e160886214c3e7d1e939918900c56e0d1aca56;p=git.git diff --git a/merge-index.c b/merge-index.c index 190e12fb7..5599fd321 100644 --- a/merge-index.c +++ b/merge-index.c @@ -1,32 +1,17 @@ -#include -#include - #include "cache.h" +#include "run-command.h" -static const char *pgm = NULL; -static const char *arguments[8]; +static const char *pgm; +static const char *arguments[9]; static int one_shot, quiet; static int err; static void run_program(void) { - int pid = fork(), status; - - if (pid < 0) - die("unable to fork"); - if (!pid) { - execlp(pgm, arguments[0], - arguments[1], - arguments[2], - arguments[3], - arguments[4], - arguments[5], - arguments[6], - arguments[7], - NULL); - die("unable to execute '%s'", pgm); - } - if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) { + struct child_process child; + memset(&child, 0, sizeof(child)); + child.argv = arguments; + if (run_command(&child)) { if (one_shot) { err++; } else { @@ -51,6 +36,7 @@ static int merge_entry(int pos, const char *path) arguments[5] = ""; arguments[6] = ""; arguments[7] = ""; + arguments[8] = NULL; found = 0; do { static char hexbuf[4][60]; @@ -62,7 +48,7 @@ static int merge_entry(int pos, const char *path) break; found++; strcpy(hexbuf[stage], sha1_to_hex(ce->sha1)); - sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode) & (~S_IFMT)); + sprintf(ownbuf[stage], "%o", ntohl(ce->ce_mode)); arguments[stage] = hexbuf[stage]; arguments[stage + 4] = ownbuf[stage]; } while (++pos < active_nr);