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 <p...@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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to