Last active
April 11, 2018 04:34
-
-
Save lintile/4f54427681e3ec2f276cadd73b24fa0b to your computer and use it in GitHub Desktop.
A little script I wrote to pull all of the raw objects out of a local git repo and decompress them
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 os | |
import zlib | |
import sys | |
from fnmatch import fnmatch | |
root = './.git/objects' | |
pattern = "*" | |
for path, subdirs, files in os.walk(root): | |
for name in files: | |
if fnmatch(name, pattern): | |
try: | |
filename = os.path.join(path, name) | |
object_raw = open(filename, 'rb').read() | |
object_full = zlib.decompress(object_raw) | |
outfile = open(name + '.dump', 'wb') | |
null_byte = object_full.find(b'\x00') | |
outfile.write(object_full[null_byte+1:]) | |
outfile.close() | |
except: | |
print 'cannot even with ' + filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment