How can I print the contents of a Git object as it is stored in the .git folder?

Viewed 936

The following commands do not produce the same output:

cat .git/objects/96/d0745960850e8ac97406311f3288b6d035cefc
git show --raw 96d0745960850e8ac97406311f3288b6d035cefc

I have tried various options to git show and git cat-file, but I cannot seem to get things to match. I feel like this should be supported somehow.

Specifically, I want the documented format. That is, I expect to see the, header, null byte, etc.

If I run:

cat .git/objects/96/d0745960850e8ac97406311f3288b6d035cefc | zlib-deflate | hexdump

I see that the line starts with:

0000000 62 6c 6f 62

which corresponds to "b" "l" "o" "b" as I would expect.

If you're curious, the contents of my zlib-deflate script are:

#!/usr/bin/env python

# Deflates a stream of bytes compressed via zlib that are passed to stdin.

import io
import sys
import zlib

# https://stackoverflow.com/q/6065173/396304
reader = io.open(sys.stdin.fileno(), mode='rb', closefd=False)
data = reader.read()
print zlib.decompress(data)
0 Answers
Related