Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Christian Couder <chriscool@tuxfamily.org>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Miklos Vajna <vmiklos@frugalware.org>,
	Jakub Narebski <jnareb@gmail.com>
Subject: Re: [RFC/PATCH v3] merge-base: teach "git merge-base" to accept more than 2 arguments
Date: Mon, 28 Jul 2008 13:33:45 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.1.00.0807281328520.2725@eeepc-johanness> (raw)
In-Reply-To: <20080728065023.743930d6.chriscool@tuxfamily.org>

Hi,

On Mon, 28 Jul 2008, Christian Couder wrote:

> +	rev = xmalloc((argc - 1) * sizeof(*rev));
> +
> +	do {
> +		struct commit *r = get_commit_reference(argv[1]);
> +		if (!r)
> +			return 1;
> +		rev[rev_nr++] = r;
> +		argc--; argv++;
> +	} while (argc > 1);
> +
> +	return show_merge_base(rev, rev_nr, show_all);

	rev = xmalloc((argc - 1) * sizeof(*rev));

	for (rev_nr = 0; rev_nr + 1 < argc; rev_nr++) {
		rev[rev_nr] = get_commit_reference(argv[rev_nr + 1]);
		if (!rev[rev_nr])
			return !!error("Does not refer to a commit: '%s'",
				argv[rev_nr + 1]);
	}

	return show_merge_base(rev, rev_nr, show_all);

I do not know about you, but I think this is not only shorter (in spite of 
adding a helpful error message), but also simpler to understand (not using 
convoluted do { } while logic), and therefore superior.

Your performance argument is weak IMHO, as this is not a big performance 
hit, and command line parameter parsing is definitely not performance 
critical.

Ciao,
Dscho

  parent reply	other threads:[~2008-07-28 11:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-28  4:50 [RFC/PATCH v3] merge-base: teach "git merge-base" to accept more than 2 arguments Christian Couder
2008-07-28  5:37 ` Junio C Hamano
2008-07-29  5:24   ` Christian Couder
2008-07-28  5:46 ` Junio C Hamano
2008-07-28 11:33 ` Johannes Schindelin [this message]
2008-07-30  4:52   ` Christian Couder
2008-07-30 13:51     ` Johannes Schindelin

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=alpine.DEB.1.00.0807281328520.2725@eeepc-johanness \
    --to=johannes.schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    --cc=vmiklos@frugalware.org \
    /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