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

Re: How pretty is pretty? git cat-file -p inconsistency

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 8, 2011, 16:36 UTC
Message-ID
<201110081836.33941.jnareb@gmail.com>
In-Reply-To
<4E906292.1020909@drmicha.warpmail.net>
On Sat, 8 Oct 2011, Michael J Gruber wrote:
> Jakub Narebski venit, vidit, dixit 08.10.2011 01:50:
Show 27 quoted lines
> > Tree object consist of zero or more entries.  Each item consist of mode,
> > filename, and sha1:
> > 
> >   <mode> SPC <filename> NUL <sha1>
> > 
> > where
> > 
> > 1. <mode> is variable-length (!) text (!) containing mode of an
> >    entry. It encodes type of entry: if it is blob (including special
> >    case: symbolic link), tree i.e. directory, or a commit
> >    i.e. submodule.  Does not include leading zeros.
> > 
> > 2. <filename> is variable-length null-terminated ("\0") name of a file
> >    or directory, or name of directory where submodule is attached
> > 
> > 3. <sha1> is 40-bytes _binary_ identifier.
> > 
> > HTH
> 
> It does help, thanks.
> 
> Though I'm beginning to think we have a crazy object format. Not only do
> we have a lot of indirections (like ascii representation of decimal
> representation of length), but we store sha1 as ascii in commit and tag
> objects and as binary in tree objects. Which makes tree objects the only
> unpleasant ones to look at (and parse) in raw form. (I was hoping we can
> dispose of/deprecate cat-file -p in favor of show). Oh well.

Well, actually we have pretty consistent format, i.e. we use textual format everywhere (textual size of blob instead of some variable-length integer, textual name of type of object instead of a byte for it, epoch as a text and not 64bit signed int in some network format, hexadecimal sha1, space separated (sub)fields)...

... with the sole exception of tree object, which uses _binary_ sha1. What was Linus thinking?!?

To have consistency the tree entry should IMVHO look like this
  <textual mode> SPC <filename> NUL <hexadecimal sha1> LF

Nb. with hexadecimal sha-1 everywhere it would be I think possible (if very very difficult) to move to different hash function: SHA-256, Skein, etc. I don't know if it is now at all possible...

-- 
Jakub Narebski
Poland
Previous: Michael J Gruber
Message 6 of 6 in “How pretty is pretty? git cat-file -p inconsistency”
  1. Michael J GruberOct 7, 2011
  2. Junio C HamanoOct 7, 2011
  3. Michael J GruberOct 7, 2011
  4. Jakub NarebskiOct 7, 2011
  5. Michael J GruberOct 8, 2011
  6. Jakub NarebskiOct 8, 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.