git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: rev-list and "ambiguous" IDs

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 19, 2019, 01:24 UTC
Message-ID
<xmqq7e3w1wvg.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191118120315.GB12766@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I think that changes the meaning of GET_OID_COMMITTISH, though. Right
> now it means "if disambiguating, prefer a committish", but not "I can
> only accept a commit". So we would still happily return an unambiguous
> object that does not match that type.
Ah, OK, so I was stupid (not a news anymore ;-)
> And that is why "git -c
> core.disambiguate=committish show $short_blob" works, for example.
Yes, and it should work that way.
Show 26 quoted lines
> Perhaps a simple fix would just be for get_short_oid()'s error message
> to mention the disambiguation rule. E.g., something like:
>
>    $ git show abcd2
>    error: short SHA1 abcd2 is ambiguous
>    hint: We would have preferred a commit or tag pointing to a commit,
>    hint: but none were found. The candidates are:
>    hint:   abcd22f55e tree
>    hint:   abcd238df0 tree
>    hint:   abcd2b1cc8 blob
>
> or
>
>   $ git show abcd2
>   error: short SHA1 abcd2 is ambiguous
>   hint: We preferred a commit or tag pointing to a commit to other
>   hint: object types, but two candidates were found:
>   hint:   abcd22f55e commit
>   hint:   abcd238df0 commit
>   hint:   abcd2b1cc8 blob
>
> (optionally the second one could even not mention the blob, though I
> think with the lead-in sentence it's OK).
>
> The verbiage there isn't great (I was trying to avoid the jargon
> "committish"), but hopefully you get the point.

Yup, if we were to do anything, this is a much more sensible thing to do than make GET_OID_<TYPE> reject objects that are not of <TYPE>, I think.

Thanks for a dose of sanity.
Previous: Jeff King
Message 13 of 13 in “rev-list and "ambiguous" IDs”
  1. Bryan TurnerNov 14, 2019
  2. Jeff KingNov 14, 2019
  3. Thomas BraunNov 15, 2019
  4. Bryan TurnerNov 15, 2019
  5. Jeff KingNov 15, 2019
  6. Jeff KingNov 15, 2019
  7. Junio C HamanoNov 15, 2019
  8. Jeff KingNov 15, 2019
  9. Junio C HamanoNov 15, 2019
  10. Thomas BraunNov 15, 2019
  11. Junio C HamanoNov 16, 2019
  12. Jeff KingNov 18, 2019
  13. Junio C HamanoNov 19, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.