X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=merge-cache.c;h=744681b24fc9a3690b5d10f50b62d5887b8ed7f3;hb=7a59013290bb26b80c997e5698757a735f1a92e0;hp=48412330cb950813b37d7254947a3f70a4fd99d8;hpb=2a45925180152b3e54248de4d7f69e8cc5c4051f;p=git.git diff --git a/merge-cache.c b/merge-cache.c index 48412330..744681b2 100644 --- a/merge-cache.c +++ b/merge-cache.c @@ -5,7 +5,7 @@ static const char *pgm = NULL; static const char *arguments[8]; -static int one_shot; +static int one_shot, quiet; static int err; static void run_program(void) @@ -27,10 +27,13 @@ static void run_program(void) die("unable to execute '%s'", pgm); } if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) { - if (one_shot) + if (one_shot) { err++; - else - die("merge program failed"); + } else { + if (!quiet) + die("merge program failed"); + exit(1); + } } } @@ -39,7 +42,7 @@ static int merge_entry(int pos, const char *path) int found; if (pos >= active_nr) - die("merge-cache: %s not in the cache", path); + die("git-merge-cache: %s not in the cache", path); arguments[0] = pgm; arguments[1] = ""; arguments[2] = ""; @@ -64,7 +67,7 @@ static int merge_entry(int pos, const char *path) arguments[stage + 4] = ownbuf[stage]; } while (++pos < active_nr); if (!found) - die("merge-cache: %s not in the cache", path); + die("git-merge-cache: %s not in the cache", path); run_program(); return found; } @@ -97,15 +100,19 @@ int main(int argc, char **argv) int i, force_file = 0; if (argc < 3) - usage("merge-cache [-o] (-a | *)"); + usage("git-merge-cache [-o] [-q] (-a | *)"); read_cache(); i = 1; - if (!strcmp(argv[1], "-o")) { + if (!strcmp(argv[i], "-o")) { one_shot = 1; i++; } + if (!strcmp(argv[i], "-q")) { + quiet = 1; + i++; + } pgm = argv[i++]; for (; i < argc; i++) { char *arg = argv[i]; @@ -118,11 +125,11 @@ int main(int argc, char **argv) merge_all(); continue; } - die("merge-cache: unknown option %s", arg); + die("git-merge-cache: unknown option %s", arg); } merge_file(arg); } - if (err) + if (err && !quiet) die("merge program failed"); - return 0; + return err; }