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

Re: [PATCH] find_unique_abbrev(): honor caller-supplied "len" better

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 11, 2011, 01:33 UTC
Message-ID
<7vmxl21lwr.fsf@alter.siamese.dyndns.org>
In-Reply-To
<AANLkTikPxSspRFQWke4=u55cmmHw8NsyizeH2gL1kD0y@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 11 quoted lines
> IOW, try your example thing not just with "master", but with two
> extreme commits. For example, try
>
>   git -c core.abbrevguard=2 rev-parse --short=5 83c3c622
>   git -c core.abbrevguard=2 rev-parse --short=4 979f7929
>
> and tell me what you get. I _think_ you should get 7 digits for the
> first case, and 8 digits for the second one. Even though you "asked"
> for a longer name in the first case, and you had the same abbrevguard.
>
> See what I'm saying? I think that's just insane.
Hmph, why?

That 979f79 one already have enough other objects with similar names, so compared to 83c3c that doesn't, it is natural that you would need more digits to protect its uniqueness, no? The result shouldn't be affected by the value of "short" as long as it is not long enough, as that is merely specifying "at least this many letters".

Another thing to realize is that without abbrevguard with the code before the configuration was introduced, you would get very similar results. With --short=5, you would get 5 letters for 83c3c622 and with --short=4, you would still need 8 letters for 979f7929. Because either of these values are not long enough and it is merely a way to specify "at least this many letters".

If we don't care about uniqueness, we can just truncate at the number of characters specified by the "len" without doing anything else. That would give us an output of uniform length without the uniqueness guarantee, and "git describe" output cannot even be fed back to git running in the same repository immediately after it is obtained. I don't think that is what we want.

Previous: Linus TorvaldsNext: Linus Torvalds
Message 9 of 18 in “Minimum git commit abbrev length (Was Re: -tip: origin tree build failure (was: [GIT PULL] ext4 update) for 2.6.37)”
  1. Ted Ts'oOct 28, 2010
  2. Linus TorvaldsOct 28, 2010
  3. Linus TorvaldsOct 28, 2010
  4. Brandon CaseyOct 29, 2010
  5. find_unique_abbrev(): honor caller-supplied "len" betterJunio C Hamano, Mar 10, 2011
  6. Linus TorvaldsMar 10, 2011
  7. Junio C HamanoMar 11, 2011
  8. Linus TorvaldsMar 11, 2011
  9. Junio C HamanoMar 11, 2011
  10. Linus TorvaldsMar 11, 2011
  11. Junio C HamanoMar 11, 2011
  12. Junio C HamanoMar 11, 2011
  13. Jeff KingMar 11, 2011
  14. Jeff KingMar 11, 2011
  15. Junio C HamanoMar 11, 2011
  16. Namhyung KimMar 13, 2011
  17. Jay SoffianMar 19, 2011
  18. Namhyung KimMar 19, 2011

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.