Skip to content

Instantly share code, notes, and snippets.

@lintile
Last active April 11, 2018 04:34
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 lintile/4f54427681e3ec2f276cadd73b24fa0b to your computer and use it in GitHub Desktop.
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
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