Created
May 31, 2016 09:56
-
-
Save wong2/866de0c9902b8e47c13f6dba246f6353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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