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

Re: [PATCH] new tutorial

From
Junio C Hamano <junkio@cox.net>
Date
Jan 16, 2006, 05:32 UTC
Message-ID
<7vmzhwybz3.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060116035731.GA14849@fieldses.org>
"J. Bruce Fields" <bfields@fieldses.org> writes:
Show 10 quoted lines
>> Empirically the first 7 hexdigits are enough (even 5 for small
>> projects such as git itself).  In fact, in the linux-2.6
>> repository itself, it appears 5 hexdigits are enough to identify
>> all 171902 objects (not just commits) uniquely currently
>
> Five hex digits is only 20 bits, and 171902/2^20 > 1/10, so each
> additional object has a better than 1-in-10 chance of colliding with an
> existing object.  The chances there hasn't been a collision in the first
> 5 digits by now must be practically zero.  Maybe you're thinking bytes,
> not hex digits?  Unless my math is wrong.
Your math is right and my script was wrong.
For linux-2.6 repository:
	$ git rev-list --objects HEAD | sort >/var/tmp/objnames
        $ wc -l </var/tmp/objnames
        171902
        $ sed -e 's/^\(........\).*/\1/' </var/tmp/objnames | uniq | wc -l
        171899
        $ sed -e 's/^\(.........\).*/\1/' </var/tmp/objnames | uniq | wc -l
        171902

So 8 is enough for most but not all objects; you need 9 to uniquely cover everybody.

Previous: J. Bruce FieldsNext: J. Bruce Fields
Message 16 of 17 in “merging initial part of a branch?”
  1. J. Bruce FieldsJan 11, 2006
  2. Junio C HamanoJan 11, 2006
  3. Andreas EricssonJan 12, 2006
  4. Junio C HamanoJan 12, 2006
  5. Andreas EricssonJan 12, 2006
  6. J. Bruce FieldsJan 12, 2006
  7. J. Bruce FieldsJan 12, 2006
  8. Junio C HamanoJan 12, 2006
  9. J. Bruce FieldsJan 13, 2006
  10. Junio C HamanoJan 13, 2006
  11. J. Bruce FieldsJan 13, 2006
  12. Junio C HamanoJan 13, 2006
  13. J. Bruce FieldsJan 13, 2006
  14. Junio C HamanoJan 15, 2006
  15. J. Bruce FieldsJan 16, 2006
  16. Junio C HamanoJan 16, 2006
  17. J. Bruce FieldsJan 23, 2006

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.