git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	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: Tue, 29 Jul 2008 07:24:15 +0200	[thread overview]
Message-ID: <200807290724.16157.chriscool@tuxfamily.org> (raw)
In-Reply-To: <7vabg2wovf.fsf@gitster.siamese.dyndns.org>

Le lundi 28 juillet 2008, Junio C Hamano a écrit :
> Christian Couder <chriscool@tuxfamily.org> writes:
>
> > +static struct commit *get_commit_reference(const char *arg)
> > +{
> > +	unsigned char revkey[20];
> > +	if (get_sha1(arg, revkey))
> > +		die("Not a valid object name %s", arg);
> > +	return lookup_commit_reference(revkey);
> > +}
>
> This returns a NULL when you feed a tree to the command, and...
>
> >  int cmd_merge_base(int argc, const char **argv, const char *prefix)
> >  {
> > +	struct commit **rev;
> >  	int show_all = 0;
> > +	int rev_nr = 0;
> >
> >  	git_config(git_default_config, NULL);
> >
> > @@ -38,15 +48,18 @@ int cmd_merge_base(int argc, const char **argv,
> > const char *prefix) usage(merge_base_usage);
> >  		argc--; argv++;
> >  	}
> > +	if (argc < 3)
> >  		usage(merge_base_usage);
> > +
> > +	rev = xmalloc((argc - 1) * sizeof(*rev));
> > +
> > +	do {
> > +		struct commit *r = get_commit_reference(argv[1]);
> > +		if (!r)
> > +			return 1;
>
> ... the command silently exits with 1.

In "master" there is:

	rev1 = lookup_commit_reference(rev1key);
	rev2 = lookup_commit_reference(rev2key);
	if (!rev1 || !rev2)
		return 1;
	return show_merge_base(rev1, rev2, show_all);

so I think you found a bug in the current code.
I will post a patch to fix it soon.

It will "die" (with an error ùmessage) in case "lookup_commit_reference" 
returns NULL. I hope it's ok.

Thanks,
Christian.

  reply	other threads:[~2008-07-29  5:21 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 [this message]
2008-07-28  5:46 ` Junio C Hamano
2008-07-28 11:33 ` Johannes Schindelin
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=200807290724.16157.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=Johannes.Schindelin@gmx.de \
    --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;
as well as URLs for NNTP newsgroup(s).