4

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)
Community
  • 1
  • 1
bolinfest
  • 3,710
  • 2
  • 27
  • 40
  • I'm not sure what it is that you want here... In the first command, you're not displaying the object, you're displaying the compressed "loose" file. If that same object were instead packed into a pack file, then it would be compressed differently... (and there would be no way to get anything like the `cat` command you provided). Do you want the object's contents (like `show` provides) or do you actually want the loose object file? (Which is really only available on the filesystem and an implementation detail; the object could be packed by git itself). – Edward Thomson Mar 10 '16 at 05:01
  • @EdwardThomson Added more details: hopefully this is clear now. – bolinfest Mar 10 '16 at 17:36
  • 2
    That's *not* part of the general object format, though. That header exists only as part of the *loose object storage*. Objects in pack files do *not* have that header, that information is stored differently in the pack file. So - again - there's no git command to provide this data because it's a detail of the storage implementation, it's not part of the actual object. – Edward Thomson Mar 10 '16 at 17:59
  • 1
    Perhaps this [link](http://stackoverflow.com/a/37105125/5784831) helps: see `$ openssl zlib -d -in .git/objects/...` – Christoph Mar 20 '17 at 13:37

0 Answers0