git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: git@vger.kernel.org, peff@peff.net, B.Steinbrink@gmx.de,
	sbejar@gmail.com
Subject: Re: [PATCH v2] rev-parse: check lookup'ed commit references for NULL
Date: Fri, 25 May 2018 10:07:32 +0900	[thread overview]
Message-ID: <xmqq36ygr19n.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180524062733.5412-1-newren@gmail.com> (Elijah Newren's message of "Wed, 23 May 2018 23:27:33 -0700")

Elijah Newren <newren@gmail.com> writes:

> I would have used a Reported-by tag for Florian and Todd, but looking at
> the bugzilla.redhat.com bug report doesn't show me Florian's email
> address.  I grepped through git logs and found two associated with that
> name, but didn't know if they were still accurate, or were a different
> Florian.  So I just went with the sentence instead.

Or write names after reported-by without any address?  There is no
law that says that a trailer's contents must be proper e-mail
addresses.  People are already known to put garbage on Cc:, for
example.

>  builtin/rev-parse.c          | 8 ++++++--
>  t/t6101-rev-parse-parents.sh | 8 ++++++++
>  2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> index a1e680b5e9..a0a0ace38d 100644
> --- a/builtin/rev-parse.c
> +++ b/builtin/rev-parse.c
> @@ -282,6 +282,10 @@ static int try_difference(const char *arg)
>  			struct commit *a, *b;
>  			a = lookup_commit_reference(&start_oid);
>  			b = lookup_commit_reference(&end_oid);
> +			if (!a || !b) {
> +				*dotdot = '.';
> +				return 0;
> +			}

We thought A..B or X...Y were a commit range, but it turns out that
it is not the case, since at least one end is not a committish.  We
simply restore the original and tell "No, this is not a range, try
to parse it as something else" to the caller by returning 0.

Makes sense.

> @@ -328,12 +332,12 @@ static int try_parent_shorthands(const char *arg)
>  		return 0;
>  
>  	*dotdot = 0;
> -	if (get_oid_committish(arg, &oid)) {
> +	if (get_oid_committish(arg, &oid) ||
> +	    !(commit = lookup_commit_reference(&oid))) {
>  		*dotdot = '^';
>  		return 0;
>  	}
>  
> -	commit = lookup_commit_reference(&oid);

OK, the logic flows the same way for things like foo^@ here, which
makes sense.

Looks good.  Thanks.


  parent reply	other threads:[~2018-05-25  1:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 19:52 BUG: rev-parse segfault with invalid input Todd Zullinger
2018-05-23 20:23 ` Elijah Newren
2018-05-23 20:45   ` Todd Zullinger
2018-05-23 20:46   ` [PATCH 1/2] t6101: add a test for rev-parse $garbage^@ Elijah Newren
2018-05-23 20:46     ` [PATCH 2/2] rev-parse: verify that commit looked up is not NULL Elijah Newren
2018-05-23 22:09       ` Jeff King
2018-05-24  6:27         ` [PATCH v2] rev-parse: check lookup'ed commit references for NULL Elijah Newren
2018-05-24 14:04           ` Todd Zullinger
2018-05-24 15:11             ` Florian Weimer
2018-05-24 17:06           ` Jeff King
2018-05-25  1:07           ` Junio C Hamano [this message]
2018-05-23 22:19       ` [PATCH 2/2] rev-parse: verify that commit looked up is not NULL Todd Zullinger
2018-05-23 22:23         ` Todd Zullinger
2018-05-23 22:12     ` [PATCH 1/2] t6101: add a test for rev-parse $garbage^@ Jeff King

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=xmqq36ygr19n.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=sbejar@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).