git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Jakub Narebski <jnareb@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: How pretty is pretty? git cat-file -p inconsistency
Date: Sat, 08 Oct 2011 16:47:46 +0200	[thread overview]
Message-ID: <4E906292.1020909@drmicha.warpmail.net> (raw)
In-Reply-To: <m3r52o1hxr.fsf@localhost.localdomain>

Jakub Narebski venit, vidit, dixit 08.10.2011 01:50:
> 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

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.

Michael

  reply	other threads:[~2011-10-08 14:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07  8:44 How pretty is pretty? git cat-file -p inconsistency Michael J Gruber
2011-10-07 18:04 ` Junio C Hamano
2011-10-07 20:26   ` Michael J Gruber
2011-10-07 23:50     ` Jakub Narebski
2011-10-08 14:47       ` Michael J Gruber [this message]
2011-10-08 16:36         ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E906292.1020909@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).