Git Storage
Git storage relies extensively on the SHA-1 hash algorithm which produces a 160-bit key for each blob and each tree node.
The values are not computed on the blobs themselves, but on a composite of:
- The utf-8 string "
blob "
- The utf-8 string for the file length
- A null byte
- The contents of the blob
So, these two commands produce equivalent results:
- echo -n Hello Git > text.txt && git hash-object text.txt
- printf "blob 9\0Hello Git" | sha1sum
Trees are computed from:
- The utf-8 string "
tree "
- The utf-8 string for the content length
- A null character
-
Zero or more content markers consisting of:
- The mask of the item
- UTF-8 space character
- The name of the item
- The 20-byte hash of the item
Commits are:
- The utf-8 string "
commit "
- The utf-8 string for the content length
- A null byte
- The utf-8 string "
tree "
- The utf-8 string for the hash
- A linefeed character
- The utf-8 string "
author "
- 1234567890 -0800]]>
- A linefeed character
- The utf-8 string "
committer "
- 1234567890 -0800]]>
- Two linefeed characters
- The commit message
- A linefeed character