I decompressed three git objects with this Python script:
import zlib
filename = '/path_to_file'
compressed_contents = open(filename, 'rb').read()
decompressed_contents = zlib.decompress(compressed_contents)
print(decompressed_contents)
for these three objects, I get these three outputs:
b'tree 32\x00100644 file\x00\xe6\x01\xe5\x92\x8e\xcc.\xc5\xbe\t\x91{\xe9\x92:\x85\xc4\x89\xe9H'
b'commit 196\x00tree 2b32fe41c7f8c21d5010fb59a59bcce42b2b3ab5\nauthor author <author> 1643729123 +0100\ncommitter author_email <author_email> 1643729123 +0100\n\nadd hello\n'
b'blob 6\x00hello\n'
In the git documentation (git probook) they say that git add a null byte at the end of the object header which is \u0000
. But when I decompress those objects with zlib, \u0000
are replaced by \x00
.
- So, what does git really store in those files,
\u0000
or\x00
? - Does this script output the
raw content
of git objects?
\u0000
and\x00
are the same thing:print(repr('\u0000'))