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

Re: [BUG] 'git merge --quiet' is not always quiet

From
Jeff King <peff@peff.net>
Date
Apr 2, 2015, 21:39 UTC
Message-ID
<20150402213952.GB22988@peff.net>
In-Reply-To
<CADwUm8do1+2aAqSnwMmViTCwA9jpAZM21DtRP9YiniVtCenFKw@mail.gmail.com>
On Thu, Apr 02, 2015 at 02:42:30PM +0200, Carl Mäsak wrote:
Show 19 quoted lines
> In the following session, a 'git merge' command shows some output even
> with the '--quiet' flag supplied.
> 
>     ~/tmp $ git init example
>     Initialized empty Git repository in /tmp/example/.git/
>     ~/tmp $ cd example/
>     ~/tmp/example $ git commit --allow-empty -m'initial commit'
>     [master (root-commit) a7329b5] initial commit
>     ~/tmp/example $ git checkout -b b1
>     Switched to a new branch 'b1'
>     ~/tmp/example $ git commit --allow-empty -m'commit on branch'
>     [b1 d15e5ac] commit on branch
>     ~/tmp/example $ git checkout master
>     Switched to branch 'master'
>     ~/tmp/example $ git merge --quiet --no-ff --no-edit b1
>     Already up-to-date!
>     ~/tmp/example $
> 
> My expectation is that '--quiet' would suppress all output, even this one.

It looks like we end up calling into merge-recursive here, but the "--quiet" flag is not passed down. This patch seems to fix it for me.

-- >8 --
Subject: merge: pass verbosity flag down to merge-recursive

This makes "git merge --quiet" really quiet when we call into merge-recursive.

Note that we can't just pass our flag down as-is; the two parts of the code use different scales. We center at "0" as normal for git-merge (with "--quiet" giving a negative value), but merge-recursive uses "2" as its center. This patch passes a negative value to merge-recursive rather than "1", though, as otherwise the user would have to use "-qqq" to squelch all messages (but the downside is that the user cannot distinguish between levels 0-2 if without resorting to the GIT_MERGE_VERBOSITY variable).

We may want to review and renormalize the message severities in merge-recursive, but that does not have to happen now. This is at least in improvement in the sense that we are respecting "--quiet" at all.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/merge.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/builtin/merge.c b/builtin/merge.c
index 3b0f8f9..068a83b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -684,6 +684,10 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 			o.subtree_shift = "";
 
 		o.renormalize = option_renormalize;
+		if (verbosity < 0)
+			o.verbosity = verbosity;
+		else if (verbosity > 0)
+			o.verbosity += verbosity;
 		o.show_rename_progress =
 			show_progress == -1 ? isatty(2) : show_progress;
 
-- 
2.4.0.rc0.363.gf9f328b
Previous: Carl Mäsak
Message 2 of 2 in “[BUG] 'git merge --quiet' is not always quiet”
  1. Carl MäsakApr 2, 2015
  2. Jeff KingApr 2, 2015

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.