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

[PATCH 1/2] Add a quiet option to git merge

From
Iustin Pop <iusty@k1024.org>
Date
Mar 8, 2008, 23:52 UTC
Message-ID
<1205020356-6682-2-git-send-email-iusty@k1024.org>
In-Reply-To
<1205020356-6682-1-git-send-email-iusty@k1024.org>

Currently it's not possible to do quiet merges in case of no changes because git merge always outputs the 'Already up to date' message.

This small patch adds a quiet option to git merge that in this case will
skip the output of this message.
---
 Documentation/git-merge.txt     |    2 +-
 Documentation/merge-options.txt |    4 ++++
 git-merge.sh                    |   19 +++++++++++++------
 3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index c136b10..0c4cd19 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -9,7 +9,7 @@ git-merge - Join two or more development histories together
 SYNOPSIS
 --------
 [verse]
-'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...
+'git-merge' [-n] [-q] [--summary] [--no-commit] [--squash] [-s <strategy>]...
 	[-m <msg>] <remote> <remote>...
 'git-merge' <msg> HEAD <remote>...
 
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 9f1fc82..dbedf40 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -5,6 +5,10 @@
 -n, \--no-summary::
 	Do not show diffstat at the end of the merge.
 
+-q, \--quiet::
+	Supress the 'Already up to date' message if no merge is
+	needed.
+
 --no-commit::
 	Perform the merge but pretend the merge failed and do
 	not autocommit, to give the user a chance to inspect and
diff --git a/git-merge.sh b/git-merge.sh
index 7dbbb1d..625457e 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -15,6 +15,7 @@ commit               perform a commit if the merge sucesses (default)
 ff                   allow fast forward (default)
 s,strategy=          merge strategy to use
 m,message=           message to be used for the merge commit (if any)
+q,quiet              suppress some default messages
 "
 
 SUBDIRECTORY_OK=Yes
@@ -38,6 +39,7 @@ use_strategies=
 allow_fast_forward=t
 allow_trivial_merge=t
 squash= no_commit=
+quiet=
 
 dropsave() {
 	rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -59,12 +61,15 @@ restorestate() {
 }
 
 finish_up_to_date () {
-	case "$squash" in
-	t)
-		echo "$1 (nothing to squash)" ;;
-	'')
-		echo "$1" ;;
-	esac
+	if test -z "$quiet"
+	then
+		case "$squash" in
+		t)
+			echo "$1 (nothing to squash)" ;;
+		'')
+			echo "$1" ;;
+		esac
+	fi
 	dropsave
 }
 
@@ -182,6 +187,8 @@ parse_config () {
 			merge_msg="$1"
 			have_message=t
 			;;
+		-q|--quiet)
+			quiet=t ;;
 		--)
 			shift
 			break ;;
-- 
1.5.4.3
Previous: Iustin PopNext: Iustin Pop
Message 2 of 7 in “Improve git pull --quiet behaviour”
  1. Iustin PopMar 8, 2008
  2. 1/2 Add a quiet option to git mergeIustin Pop, Mar 8, 2008
  3. Add a quiet option to git mergeIustin Pop, Mar 9, 2008
  4. 2/2 Fix git pull handling of the quiet optionIustin Pop, Mar 8, 2008
  5. Junio C HamanoMar 9, 2008
  6. Iustin PopMar 9, 2008
  7. Fix git pull handling of the quiet optionIustin Pop, Mar 9, 2008

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.