# [BUG] 'git merge --quiet' is not always quiet

2 messages from 2015-04-02 to 2015-04-02. Participants: Carl Mäsak, Jeff King.
Thread: https://gitlist.dev/t/38977

## Carl Mäsak, 2015-04-02 12:42

Subject: [BUG] 'git merge --quiet' is not always quiet
Message-ID: <CADwUm8do1+2aAqSnwMmViTCwA9jpAZM21DtRP9YiniVtCenFKw@mail.gmail.com>
URL: https://gitlist.dev/e/CADwUm8do1%2B2aAqSnwMmViTCwA9jpAZM21DtRP9YiniVtCenFKw%40mail.gmail.com

```
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.

I'm on Git 1.9.1, but I've been informed on IRC that this happens even
on latest.

// Carl

```

## Jeff King, 2015-04-02 21:39

Subject: Re: [BUG] 'git merge --quiet' is not always quiet
Message-ID: <20150402213952.GB22988@peff.net>
URL: https://gitlist.dev/e/20150402213952.GB22988%40peff.net
In-Reply-To: <CADwUm8do1+2aAqSnwMmViTCwA9jpAZM21DtRP9YiniVtCenFKw@mail.gmail.com>

```
On Thu, Apr 02, 2015 at 02:42:30PM +0200, Carl Mäsak wrote:

> 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

```
