git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: tuncer.ayaz@gmail.com
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
Date: Mon, 13 Oct 2008 15:13:03 -0700	[thread overview]
Message-ID: <7vzll887ps.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1223934148-13942-1-git-send-email-tuncer.ayaz@gmail.com> (tuncer ayaz's message of "Mon, 13 Oct 2008 23:42:28 +0200")

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?

> 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?

> +		if (verbose || !quiet)
> +			printf("Updating %s..%s\n",
> +				hex,
> +				find_unique_abbrev(remoteheads->item->object.sha1,
> +				DEFAULT_ABBREV));

Ditto.

  reply	other threads:[~2008-10-13 22:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-13 21:42 [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose tuncer.ayaz
2008-10-13 22:13 ` Junio C Hamano [this message]
2008-10-13 22:29   ` Tuncer Ayaz
     [not found]     ` <4ac8254d0810151047p7e12e8efk6fea666d2ac85f0f@mail.gmail.com>
     [not found]       ` <7vy70p3cga.fsf@gitster.siamese.dyndns.org>
     [not found]         ` <4ac8254d0810151220l48b81325yf3aca48cda49ef3a@mail.gmail.com>
     [not found]           ` <7vprm1pfmd.fsf@gitster.siamese.dyndns.org>
2008-10-16  5:54             ` Tuncer Ayaz
2008-10-16  6:15               ` Junio C Hamano
2008-10-16 20:08                 ` Tuncer Ayaz
  -- strict thread matches above, loose matches on Subject: below --
2008-10-12 16:54 Tuncer Ayaz
2008-10-12 20:08 ` Shawn O. Pearce
2008-10-12 20:29   ` Tuncer Ayaz
2008-10-12 21:31   ` Tuncer Ayaz
2008-10-12 21:36     ` Tuncer Ayaz
2008-10-13 21:03       ` Tuncer Ayaz
2008-10-13 21:06         ` Shawn O. Pearce
2008-10-13 21:12           ` Tuncer Ayaz
2008-10-13 21:13             ` Shawn O. Pearce
2008-10-13 21:44               ` Tuncer Ayaz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vzll887ps.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=tuncer.ayaz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).