Skip to content

Instantly share code, notes, and snippets.

@wong2
Created May 31, 2016 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wong2/866de0c9902b8e47c13f6dba246f6353 to your computer and use it in GitHub Desktop.
Save wong2/866de0c9902b8e47c13f6dba246f6353 to your computer and use it in GitHub Desktop.
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