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

Re: [PATCH/RFC] get_sha1: prefer 40-hex ref name over 40-hex SHA-1

From
Duy Nguyen <pclouds@gmail.com>
Date
May 2, 2013, 10:09 UTC
Message-ID
<CACsJy8AOEEAJ6jtcaAWmrfCbejq8SLcEsUNSsrOEJ6he+5CByA@mail.gmail.com>
In-Reply-To
<20130501184327.GM24467@google.com>
On Thu, May 2, 2013 at 1:43 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 11 quoted lines
> Nguyễn Thái Ngọc Duy wrote:
>
>>                                              "git rev-parse 1234" will
>> resolve refs/heads/1234 if exists even if there is an unambiguous
>> SHA-1 starting with 1234. However if it's full SHA-1, the SHA-1 takes
>> precedence and refs with the same name are ignored.
>
> That's an important feature for safety.  When a script has created an
> object or learned about it some other way, as long as it doesn't
> abbreviate its name it can be sure that git commands will not
> misunderstand it.

Then what about abbrev sha-1? You pick up an abbrev sha-1 from "git log --oneline", do "git show <abbrev>". If you happen to have refs/heads/<abbrev> then what you see is not what you intend to see. Warn about ambiguity and move on? Banning all sha1-alike refs seems unreasonable (or not? I don't know).

> So I think this is a bad change.  Maybe check-ref-format should
> reject 40-hexdigit refnames?

I tried that first. The test suite screamed. Will do that again and figure out soon. -- Duy

Previous: Jonathan NiederNext: Nguyễn Thái Ngọc Duy
Message 4 of 8 in “get_sha1: prefer 40-hex ref name over 40-hex SHA-1”
  1. get_sha1: prefer 40-hex ref name over 40-hex SHA-1Nguyễn Thái Ngọc Duy, May 1, 2013
  2. Eric SunshineMay 1, 2013
  3. Jonathan NiederMay 1, 2013
  4. Duy NguyenMay 2, 2013
  5. get_sha1: improve ambiguity warning regarding SHA-1 and ref namesNguyễn Thái Ngọc Duy, May 4, 2013
  6. Junio C HamanoMay 7, 2013
  7. get_sha1: warn about full or short object names that look like refsNguyễn Thái Ngọc Duy, May 29, 2013
  8. Thomas RastMay 2, 2013

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.