Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:45:28
tuncer.ayaz@gmail.com writes:
From: Tuncer Ayaz <redacted> Updated patch to current Junio master.
That's not a commit log message, is it?
quoted hunk
Signed-off-by: Tuncer Ayaz <redacted> --- Documentation/merge-options.txt | 8 ++++++++ builtin-fetch.c | 5 +++-- builtin-merge.c | 22 +++++++++++++++------- git-pull.sh | 10 ++++++++-- 4 files changed, 34 insertions(+), 11 deletions(-)diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 007909a..427cdef 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt@@ -1,3 +1,11 @@ +-q:: +--quiet:: + Operate quietly. + +-v:: +--verbose:: + Be verbose. + --stat:: Show a diffstat at the end of the merge. The diffstat is also controlled by the configuration option merge.stat.diff --git a/builtin-fetch.c b/builtin-fetch.c index ee93d3a..287ce33 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c@@ -372,12 +372,13 @@ static int store_updated_refs(const char *url, const char *remote_name, SUMMARY_WIDTH, *kind ? kind : "branch", REFCOL_WIDTH, *what ? what : "HEAD"); if (*note) { - if (!shown_url) { + if ((verbose || !quiet) && !shown_url) {
A pair of external verbosity flag -q and -v may be acceptable, but is it
sane to have a pair of variables in code always used like this? In other
words, this makes me wonder if a single "verbosity level" variable that
can be set to quiet, normal and verbose would make it more readable. For
example, this one would say:
if (verbosity >= VERBOSITY_NORMAL && !shown_url) {
...
}
Also what does your command line parsing code do when the user gives -q
and -v at the same time? Does the last one on the command line win?
Shouldn't you instead get an error message (which of course would mean you
would need to fix the caller in git-pull.sh)?
+ if (verbose || !quiet) + fprintf(stderr, " %s\n", note);
Ditto.
+ if (verbose || !quiet)
+ printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);Ditto.
+ if (verbose || !quiet)
+ printf("%s\n", msg);
+ if ((verbose || !quiet) && !merge_msg.len)Ditto.
+ if (!verbose && quiet) + show_diffstat = 0;
Hmph, ah, that's (!(verbose || !quiet)). See the readability issue?
+ if (verbose || !quiet)
+ printf("Updating %s..%s\n",
+ hex,
+ find_unique_abbrev(remoteheads->item->object.sha1,
+ DEFAULT_ABBREV));Ditto.