Skip to content

Instantly share code, notes, and snippets.

@wong2
Created May 31, 2016 09:56
Embed
What would you like to do?
import re
import zlib
def show_git_tree(sha1):
path = '.git/objects/%s/%s' % (sha1[:2], sha1[2:])
with open(path) as fp:
content = zlib.decompress(fp.read())
header, body = content.split('\0', 1)
for line in re.findall('(\d+) (.*?)\0(.{20})', body, re.MULTILINE):
print line[0], line[1], line[2].encode('hex')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment