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

Re: Low-level repository inspection (Re: Where do I stick development documentation?)

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 12, 2010, 03:40 UTC
Message-ID
<AANLkTikpT=PD0Q8d=6=989N6rxYXH-Le3Go_szAz-t4s@mail.gmail.com>
In-Reply-To
<20100812031756.GD19174@burratino>
On Thu, Aug 12, 2010 at 03:17, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 8 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>
>> It'd also be very neat if we had tools to print out any object in its
>> raw form, --pretty=raw is partly there, but it's more pretty than
>> raw.
>
> How about git cat-file (and other “interrogation commands” listed in
> git.1)?

Those are part of the way there, but you often have to tease info out of them, e.g. if you want a commit -> commit roundtrip:

    $ echo 7980e417 | git cat-file --batch | perl -0777 -pe 's/.*
commit ([0-9]*).(.*)\n/commit $1\0$2/s'|sha1sum
    7980e41746bc5de91eea775f9142ce44b1100361  -
The raw output from that is:
    $ echo 7980e417 | git cat-file --batch
    7980e41746bc5de91eea775f9142ce44b1100361 commit 525
    tree 782007df51255ab3793e528a4b5c4a69342166f2
    parent 0d0ba03a18a9c6cbc3d55c1b6834b9c3824f823f
    parent b5e233ecc411c8685463333d180a135c6866c50e
    author Junio C Hamano <gitster@pobox.com> 1281551520 -0700
    committer Junio C Hamano <gitster@pobox.com> 1281551520 -0700
    Merge branch 'maint'
    * maint:
      post-receive-email: remove spurious commas in email subject
      fast-import: export correctly marks larger than 2^20-1
      t/lib-git-svn.sh: use $PERL_PATH for perl, not perl from $PATH
      diff: strip extra "/" when stripping prefix
It'd be nice to answer "how are object stored" with something like:
    $ echo 7980e417 | git some-thing --pretty=raw -
    commit <SP> 525 <NULL>
    tree ....

And be able to do something similar to see what's stored in an arbitrary pack file, I've often wished I had something like that when using git-fsck.

These docs are also an excellent resource, afaict we only hint at something like this in git, e.g. in the git-cat-file(1) manpage: http://www-cs-students.stanford.edu/~blynn/gitmagic/ch08.html

Previous: Jonathan NiederNext: Jonathan Nieder
Message 5 of 11 in “Where do I stick development documentation?”
  1. Ævar Arnfjörð BjarmasonAug 11, 2010
  2. Jonathan NiederAug 12, 2010
  3. Ævar Arnfjörð BjarmasonAug 12, 2010
  4. Low-level repository inspection (Re: Where do I stick development documentation?)Jonathan Nieder, Aug 12, 2010
  5. Ævar Arnfjörð BjarmasonAug 12, 2010
  6. Jonathan NiederAug 12, 2010
  7. Michael WittenAug 12, 2010
  8. Ævar Arnfjörð BjarmasonAug 12, 2010
  9. Jonathan NiederAug 12, 2010
  10. Jonathan NiederAug 12, 2010
  11. Ævar Arnfjörð BjarmasonAug 12, 2010

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.