Created
March 21, 2023 09:04
-
-
Save gekart/dcb4952fa2b80f1098da6cc68ccfc908 to your computer and use it in GitHub Desktop.
Display compressed Git object contents
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
#!/usr/bin/python3 | |
import zlib | |
import hashlib | |
import sys | |
if len(sys.argv) != 2: | |
print("Usage:", sys.argv[0], " <path-to-git-object>") | |
exit(-1) | |
filename = sys.argv[1] | |
compressed_contents = open(filename, 'rb').read() | |
decompressed_contents = zlib.decompress(compressed_contents) | |
print("Uncompressed contents:") | |
print(decompressed_contents) | |
print() | |
print("Total length:", len(decompressed_contents)) | |
print() | |
hash_value = hashlib.sha1(decompressed_contents).hexdigest() | |
print("sha-1:", hash_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example
print-object.py project-1/.git/objects/8c/674a054d745b23a2f199cffb3fdef5576d916e