Created
May 14, 2013 04:40
-
-
Save kejinlu/5573737 to your computer and use it in GitHub Desktop.
Verify git object with python!
This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import zlib,os,sys,hashlib | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
if len(sys.argv) < 2: | |
print "Need the path of git object!" | |
exit() | |
filePath = sys.argv[1] | |
fp = open(os.path.expanduser(filePath)) | |
str = fp.read() | |
fp.close() | |
str = zlib.decompress(str) | |
print str | |
gitsha1 = hashlib.sha1() | |
gitsha1.update(str) | |
print gitsha1.hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python gitverify.py ~/Projects/mygit/.git/objects/61/f26c0d181a3f3ae6c0db23c775856760040502