From: Petr Baudis Date: Fri, 29 Jul 2005 12:53:38 +0000 (+0200) Subject: [PATCH] git-merge-cache -q doesn't complain about failing merge program X-Git-Tag: v0.99.3~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bbd14cb0113ca26d679970f4db9ad953fb273e36;p=git.git [PATCH] git-merge-cache -q doesn't complain about failing merge program git-merge-cache reporting failed merge program is undesirable for Cogito, since it emits its own more appropriate error message in that case. However, I want to show other possible git-merge-cache error messages. So -q will just silence this particular error. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-merge-cache.txt b/Documentation/git-merge-cache.txt index 3fb4d492..f1fbb5dd 100644 --- a/Documentation/git-merge-cache.txt +++ b/Documentation/git-merge-cache.txt @@ -9,7 +9,7 @@ git-merge-cache - Runs a merge for files needing merging SYNOPSIS -------- -'git-merge-cache' [-o] (-a | -- | \*) +'git-merge-cache' [-o] [-q] (-a | -- | \*) DESCRIPTION ----------- @@ -32,6 +32,11 @@ OPTIONS returned errors, and only return the error code after all the merges are over. +-q:: + Do not complain about failed merge program (the merge program + failure usually indicates conflicts during merge). This is for + porcelains which might want to emit custom messages. + If "git-merge-cache" is called with multiple s (or -a) then it processes them in turn only stopping if merge returns a non-zero exit code. @@ -40,7 +45,7 @@ Typically this is run with the a script calling the merge command from the RCS package. A sample script called "git-merge-one-file-script" is included in the -ditribution. +distribution. ALERT ALERT ALERT! The git "merge object order" is different from the RCS "merge" program merge object order. In the above ordering, the diff --git a/merge-cache.c b/merge-cache.c index 37c72d26..b2893e6e 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); + } } } @@ -97,15 +100,19 @@ int main(int argc, char **argv) int i, force_file = 0; if (argc < 3) - usage("git-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]; @@ -122,7 +129,7 @@ int main(int argc, char **argv) } merge_file(arg); } - if (err) + if (err && quiet) die("merge program failed"); - return 0; + return err; }