git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/2] git-merge-cache -q doesn't complain about failing merge program

From
Petr Baudis <pasky@suse.cz>
Date
Jul 29, 2005, 12:53 UTC
Message-ID
<20050729125338.GB21909@pasky.ji.cz>
In-Reply-To
<20050729085819.GL24895@pasky.ji.cz>

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 <pasky@ucw.cz>
---

There's more of patches to come. All those which are overflowing this series are in the git-pb branch as well and you'd get them by pulling it.

commit 8ddefe85adc8e035864be615c87844ef982f4bc6 tree d5e6c49f93d2e4138ad63faa7fcfb893f4843c88 parent 527a155a0400df1af2e1da64fc02f2dd003413a8 author Petr Baudis <pasky@suse.cz> Fri, 29 Jul 2005 14:52:53 +0200 committer Petr Baudis <xpasky@machine.sinus.cz> Fri, 29 Jul 2005 14:52:53 +0200

 Documentation/git-merge-cache.txt |    9 +++++++--
 merge-cache.c                     |   23 +++++++++++++++--------
 2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/Documentation/git-merge-cache.txt b/Documentation/git-merge-cache.txt
--- a/Documentation/git-merge-cache.txt
+++ b/Documentation/git-merge-cache.txt
@@ -9,7 +9,7 @@ git-merge-cache - Runs a merge for files
 
 SYNOPSIS
 --------
-'git-merge-cache' [-o] <merge-program> (-a | -- | <file>\*) 
+'git-merge-cache' [-o] [-q] <merge-program> (-a | -- | <file>\*) 
 
 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 <file>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 
 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
--- 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] <merge-program> (-a | <filename>*)");
+		usage("git-merge-cache [-o] [-q] <merge-program> (-a | <filename>*)");
 
 	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;
 }
Previous: Matthias UrlichsNext: Junio C Hamano
Message 6 of 21 in “Bits from git-pb”
  1. 0/2 Bits from git-pbPetr Baudis, Jul 29, 2005
  2. 1/2 Trivial tidyupsPetr Baudis, Jul 29, 2005
  3. 2/2 Unify usage strings declarationPetr Baudis, Jul 29, 2005
  4. Junio C HamanoJul 30, 2005
  5. Matthias UrlichsJul 30, 2005
  6. 3/2 git-merge-cache -q doesn't complain about failing merge programPetr Baudis, Jul 29, 2005
  7. Junio C HamanoJul 30, 2005
  8. 4/2 Improve the compilation-time settings interfacePetr Baudis, Jul 29, 2005
  9. Petr BaudisJul 29, 2005
  10. 5/2 Remove the explicit Makefile dependencies descriptionPetr Baudis, Jul 29, 2005
  11. 6/2 Reorder Makefile rulesPetr Baudis, Jul 29, 2005
  12. 7/2 Support for NO_OPENSSLPetr Baudis, Jul 29, 2005
  13. Linus TorvaldsJul 30, 2005
  14. Junio C HamanoJul 30, 2005
  15. Under NO_OPENSSL -lssl should not be usedJunio C Hamano, Jul 30, 2005
  16. Linus TorvaldsJul 30, 2005
  17. Jon SeymourAug 2, 2005
  18. 8/2 Build commands through object filesPetr Baudis, Jul 29, 2005
  19. Petr BaudisJul 30, 2005
  20. Junio C HamanoJul 30, 2005
  21. Junio C HamanoJul 30, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.