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

Re: Why SHA are 40 bytes? (aka looking for flames)

From
Shawn O. Pearce <spearce@spearce.org>
Date
Apr 24, 2007, 02:30 UTC
Message-ID
<20070424023035.GK17480@spearce.org>
In-Reply-To
<462D5370.8040905@zytor.com>
"H. Peter Anvin" <hpa@zytor.com> wrote:
Show 8 quoted lines
> Nicolas Pitre wrote:
> >
> >Object names aren't 40 bytes.  They are 20 bytes.
> >It  is their hex representation that takes 40 bytes.
> >
> 
> Sure, but that's the way they're stored in *most* git objects, in 
> particular in commit objects.

But OBJ_TREE occurs more often, and its 20 bytes binary for a SHA-1 in those. They are only ASCII hex in OBJ_COMMIT and OBJ_TAG.

If Nico and I ever get pack v4 done, all SHA-1s drop to 24 bytes worst case, or 20 + (4 * n_references) best case. Typically we found that n_references was large enough, frequently enough, that we shaved 5% or so off linux-2.6.git. And I don't think that's including the 20 * n_objects saved out of the .idx files...

-- 
Shawn.
Previous: H. Peter AnvinNext: Nicolas Pitre
Message 17 of 18 in “Why SHA are 40 bytes? (aka looking for flames)”
  1. Marco CostalbaApr 21, 2007
  2. Andy ParkinsApr 21, 2007
  3. Karl HasselströmApr 21, 2007
  4. Marco CostalbaApr 21, 2007
  5. Marco CostalbaApr 21, 2007
  6. Jon SmirlApr 21, 2007
  7. Marco CostalbaApr 21, 2007
  8. Jon SmirlApr 21, 2007
  9. Marco CostalbaApr 21, 2007
  10. Jon SmirlApr 21, 2007
  11. Andreas EricssonApr 24, 2007
  12. Nicolas PitreApr 24, 2007
  13. Andreas EricssonApr 24, 2007
  14. Nicolas PitreApr 24, 2007
  15. Nicolas PitreApr 22, 2007
  16. H. Peter AnvinApr 24, 2007
  17. Shawn O. PearceApr 24, 2007
  18. Nicolas PitreApr 24, 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.