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

Re: Distribution of longest common hash prefixes

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Apr 3, 2007, 19:27 UTC
Message-ID
<Pine.LNX.4.64.0704031219430.6730@woody.linux-foundation.org>
In-Reply-To
<7vhcrxz5a8.fsf@assigned-by-dhcp.cox.net>
On Tue, 3 Apr 2007, Junio C Hamano wrote:
> 
> Are you hinting to update sha1_name.c::get_sha1() so that we do
> not accept abbreviated non-commit object names?

No, but it might be nice if we had some fairly graceful way of handling abbreviated SHA1's that ended up being ambiguous (maybe they weren't ambiguous in the original context, but became ambiguous later).

Some way of just listing the alternatives, and sorting - and showing - by type (so that if you know it's supposed to be a commit, you can trivially pick it out from other objects that happen to collide in the first <n> digits).

Right now we can do it with
	git-rev-list --objects --all | grep '^<abbrev-sha1>'

but that's actually not even correct (maybe the reason sha1_name decided it was ambiguous was due to an _unreachable_ SHA1?), and it's also very inefficient.

We could have some helper that just looked things up (it's easy enough to look up all potential SHA1 matches both in the filesystem and in a pack-file - no need for any rev-list thing that lists all objects).

Is this a pressing concern? Absolutely not. I don't think we've ever had any real problems with this, and you *can* do it by hand with a bit of inefficient scripting right now..

			Linus
Previous: Junio C HamanoNext: Nicolas Pitre
Message 12 of 20 in “Distribution of longest common hash prefixes”
  1. Peter EriksenApr 2, 2007
  2. Linus TorvaldsApr 2, 2007
  3. Randal L. SchwartzApr 2, 2007
  4. Linus TorvaldsApr 2, 2007
  5. Randal L. SchwartzApr 2, 2007
  6. Randal L. SchwartzApr 2, 2007
  7. James CloosApr 3, 2007
  8. Randal L. SchwartzApr 3, 2007
  9. Shawn O. PearceApr 3, 2007
  10. Linus TorvaldsApr 3, 2007
  11. Junio C HamanoApr 3, 2007
  12. Linus TorvaldsApr 3, 2007
  13. Nicolas PitreApr 3, 2007
  14. Junio C HamanoApr 3, 2007
  15. Nicolas PitreApr 3, 2007
  16. Olivier GalibertApr 3, 2007
  17. Linus TorvaldsApr 3, 2007
  18. James CloosApr 4, 2007
  19. James CloosApr 2, 2007
  20. Peter EriksenApr 2, 2007

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.