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

Re: Exact format of tree objets

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 12, 2013, 14:06 UTC
Message-ID
<loom.20130612T160455-551@post.gmane.org>
In-Reply-To
<7v4nd4bigv.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster <at> pobox.com> writes:
Show 17 quoted lines
> Chico Sokol <chico.sokol <at> gmail.com> writes:
> 
> > Is there any official documentation of tree objets format? Are tree
> > objects encoded specially in some way? How can I parse the inflated
> > contents of a tree object?
> >
> > We're suspecting that there is some kind of special format or
> > encoding, because the command "git cat-file -p <sha>" show me ...
> > While "git cat-file tree <sha>" generate ...
> 
> "cat-file -p" is meant to be human-readable form.  The latter gives
> the exact byte contents read_sha1_file() sees, which is a binary
> format.  Essentially, it is a sequence of:
> 
>  - mode of the entry encoded in octal, without any leading '0' pad;
>  - pathname component of the entry, terminated with NUL;
>  - 20-byte SHA-1 object name.

I always wondered why this is the sole object format where SHA-1 is in 20- byte binary format and not 40-chars hexadecimal string format...

-- 
Jakub Narębski
Previous: Junio C HamanoNext: Chico Sokol
Message 6 of 7 in “Exact format of tree objets”
  1. Chico SokolJun 11, 2013
  2. Ilari LiusvaaraJun 11, 2013
  3. Chico SokolJun 18, 2013
  4. Thomas RastJun 18, 2013
  5. Junio C HamanoJun 11, 2013
  6. Jakub NarebskiJun 12, 2013
  7. Chico SokolJun 18, 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.