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

Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 13, 2008, 22:13 UTC
Message-ID
<7vzll887ps.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1223934148-13942-1-git-send-email-tuncer.ayaz@gmail.com>
tuncer.ayaz@gmail.com writes:
> From: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>
> Updated patch to current Junio master.
That's not a commit log message, is it?
Show 34 quoted lines
> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
> ---
>  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?
Show 5 quoted lines
> +		if (verbose || !quiet)
> +			printf("Updating %s..%s\n",
> +				hex,
> +				find_unique_abbrev(remoteheads->item->object.sha1,
> +				DEFAULT_ABBREV));
Ditto.
Previous: tuncer.ayaz@gmail.comNext: Tuncer Ayaz
Message 2 of 6 in “Teach/Fix git-pull/git-merge --quiet and --verbose”
  1. Teach/Fix git-pull/git-merge --quiet and --verbosetuncer.ayaz@gmail.com, Oct 13, 2008
  2. Junio C HamanoOct 13, 2008
  3. Tuncer AyazOct 13, 2008
  4. Tuncer AyazOct 16, 2008
  5. Junio C HamanoOct 16, 2008
  6. Tuncer AyazOct 16, 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.