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 7, 2011, 23:50 UTC
Message-ID
<m3r52o1hxr.fsf@localhost.localdomain>
In-Reply-To
<4E8F6088.8060300@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
[cut]
> I never knew how ugly the output of "git tag-file tree sha1" is. I guess
> it's the type of object whose format I don't know... We don't have an
> object format description in Doc/technical, do we? tree.c doesn't tell
> me much.

I had to handle this in my attempt to write "git blame <directory>" in Perl, which was using `git cat-file --batch`, and that gives raw data and not pretty-printed.

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
-- 
Jakub Narębski
Previous: Michael J GruberNext: Michael J Gruber
Message 4 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.