All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
Date: Sun, 12 Oct 2008 13:08:33 -0700	[thread overview]
Message-ID: <20081012200833.GC5255@spearce.org> (raw)
In-Reply-To: <4ac8254d0810120954x2364054ahf2d49d6fbb7b0bb1@mail.gmail.com>

Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
> After fixing clone -q I noticed that pull -q is does not do what
> it's supposed to do and implemented --quiet/--verbose by
> adding it to builtin-merge and fixing two places in builtin-fetch.
 
> diff --git a/builtin-merge.c b/builtin-merge.c
> index 38266ba..1f601d4 100644
> --- a/builtin-merge.c
> +++ b/builtin-merge.c
> @@ -101,7 +102,7 @@ static struct strategy *get_strategy(const char *name)
>  			struct cmdname *ent = main_cmds.names[i];
>  			for (j = 0; j < ARRAY_SIZE(all_strategy); j++)
>  				if (!strncmp(ent->name, all_strategy[j].name, ent->len)
> -						&& !all_strategy[j].name[ent->len])
> +					&& !all_strategy[j].name[ent->len])

This hunk seems to just be whitespace formatting.  I'd rather not
see it in a patch that is otherwise about --quiet/--verbose changes.
One change per patch, please.  ;-)

> @@ -282,18 +287,20 @@ static void squash_message(void)
>  	if (prepare_revision_walk(&rev))
>  		die("revision walk setup failed");
> 
> -	strbuf_init(&out, 0);
> -	strbuf_addstr(&out, "Squashed commit of the following:\n");
> -	while ((commit = get_revision(&rev)) != NULL) {
> -		strbuf_addch(&out, '\n');
> -		strbuf_addf(&out, "commit %s\n",
> -			sha1_to_hex(commit->object.sha1));
> -		pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,
> -			NULL, NULL, rev.date_mode, 0);
> +	if(verbose || !quiet) {
> +		strbuf_init(&out, 0);
> +		strbuf_addstr(&out, "Squashed commit of the following:\n");
> +		while ((commit = get_revision(&rev)) != NULL) {
> +			strbuf_addch(&out, '\n');
> +			strbuf_addf(&out, "commit %s\n",
> +						sha1_to_hex(commit->object.sha1));
> +			pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,
> +								NULL, NULL, rev.date_mode, 0);
> +		}
> +		write(fd, out.buf, out.len);
> +		close(fd);
> +		strbuf_release(&out);
>  	}
> -	write(fd, out.buf, out.len);
> -	close(fd);
> -	strbuf_release(&out);

This entire hunk strikes me as being completely wrong.  The fd
we are writing to is SQUASH_MSG.  It was opened earlier in the
function and should be closed, even if we put nothing into the
file.  Your change causes --quiet to leak the file descriptor.

But even worse, I think your change causes SQUASH_MSG to lose its
entire content, which makes "git merge --quiet --squash" behave
very differently from what it does today, where it at least gives
you a summary of the commits in the SQUASH_MSG file.

IMHO this hunk shouldn't be here.

> @@ -877,6 +885,8 @@ int cmd_merge(int argc, const char **argv, const
> char *prefix)
> 
>  	argc = parse_options(argc, argv, builtin_merge_options,
>  			builtin_merge_usage, 0);
> +	if(!verbose && quiet)
> +		show_diffstat = 0;

Formatting nit, use "if (".

> @@ -1019,11 +1029,11 @@ int cmd_merge(int argc, const char **argv,
> const char *prefix)
>  		char hex[41];
> 
>  		strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
> -
> -		printf("Updating %s..%s\n",
> -			hex,
> -			find_unique_abbrev(remoteheads->item->object.sha1,
> -			DEFAULT_ABBREV));
> +		if(verbose || !quiet)

Formatting nit, use "if (".

> diff --git a/git-pull.sh b/git-pull.sh
> index 75c3610..d84ceb5 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -16,13 +16,17 @@ cd_to_toplevel
>  test -z "$(git ls-files -u)" ||
>  	die "You are in the middle of a conflicted merge."
> 
> -strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
> +quiet= verbose= strategy_args= no_stat= no_commit= squash= no_ff= log_arg=

This line got a little long, maybe put the two new ones on a new
line so we don't overrun the 80 column margin and there's an easier
to read diff?

-- 
Shawn.

  reply	other threads:[~2008-10-12 20:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-12 16:54 [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose Tuncer Ayaz
2008-10-12 20:08 ` Shawn O. Pearce [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2008-10-13 21:42 tuncer.ayaz
2008-10-13 22:13 ` Junio C Hamano
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

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=20081012200833.GC5255@spearce.org \
    --to=spearce@spearce.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.