All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Cc: Jeff King <peff@peff.net>, Bryan Turner <bturner@atlassian.com>,
	Git Users <git@vger.kernel.org>
Subject: Re: rev-list and "ambiguous" IDs
Date: Sat, 16 Nov 2019 12:47:20 +0900	[thread overview]
Message-ID: <xmqqmucw4h4n.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <917e2664-6059-c190-30fd-02f3cf7aa5dc@virtuell-zuhause.de> (Thomas Braun's message of "Sat, 16 Nov 2019 00:38:27 +0100")

Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:

>> But if I choose another prefix that has no commits at all, it's
>> ambiguous under either, because the "committish" rule has no way to
>> decide:
>> 
>>   $ git show abcd2
>>   error: short SHA1 abcd2 is ambiguous
>>   hint: The candidates are:
>>   hint:   abcd22f55e tree
>>   hint:   abcd238df0 tree
>>   hint:   abcd2b1cc8 blob
>>   
>>   $ git log abcd2
>>   error: short SHA1 abcd2 is ambiguous
>>   hint: The candidates are:
>>   hint:   abcd22f55e tree
>>   hint:   abcd238df0 tree
>>   hint:   abcd2b1cc8 blob
>
> I would have expected that git log did just tell me that it could not
> find something commitish, instead it told me that there are multiple
> candidates, all of them being no commit.

With this, I 100% agree with.   The latter should instead say

    $ git log abcd2 [--]
    error: bad revision 'abcd2'

just like the case where no object has abcd2 as prefix.

When we ask for commit-ish or any specific type in general, there
are a few possible cases.

 - There is only one such object that has the prefix and is
   compatible with the type.  We handle this correctly---yield that
   object and do not complain about ambiguity.

 - There are two or more such objects, or there is no such object.
   We show all objects that share the prefix, regardless of the
   type, which is way suboptimal.

An improvement can be localized to sha1-name.c::get_short_oid(), I
would think.  We know what type we want (e.g. GET_OID_COMMITTISH)
in the function, so we should be able to teach collect_ambiguous() 
to discard an object with the given prefix but of a wrong type.


  reply	other threads:[~2019-11-16  3:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14  4:35 rev-list and "ambiguous" IDs Bryan Turner
2019-11-14  5:59 ` Jeff King
2019-11-15  0:12   ` Thomas Braun
2019-11-15  3:49     ` Jeff King
2019-11-15 23:38       ` Thomas Braun
2019-11-16  3:47         ` Junio C Hamano [this message]
2019-11-18 12:03           ` Jeff King
2019-11-19  1:24             ` Junio C Hamano
2019-11-15  5:07     ` Junio C Hamano
2019-11-15  8:16       ` Jeff King
2019-11-15 11:23         ` Junio C Hamano
2019-11-15  1:19   ` Bryan Turner
2019-11-15  3:57     ` 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=xmqqmucw4h4n.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=bturner@atlassian.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=thomas.braun@virtuell-zuhause.de \
    /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.