I've successfully been able to figure out how to piece together a Git commit hash from the data.
I can construct an algorithm that makes a Call to SHA-1 using each "piece" of information (tree, author, committer, etc) and surprisingly enough, my hash matches up with the git hash the commit gets. Based on my experimentation, there is some strangeness with newlines but the format for how these should be handled is something like:
tree ***\n
parent ***\n
author *** *** ***\n
commiter *** *** ***\n
gpgsig ***\n
\n***\n
Where *** represents the actual normal input.
Now I am trying to do the same for annotated tags, but struggling to get the same SHA-1 output that git gives.
Some obvious differences stand out:
- the message now comes before the PGP sig
- the PGP sig is not prefixed with "gpgsig "
No matter how many combinations of weird newlines I try, I cannot get my algorithm to correctly build a SHA-1 hash based on this output.
The most logical format for how I see this is:
object ***\n
type ***\n
tag ***\n
tagger *** *** ***\n
\n***\n
***\n
Questions:
- Is there anything else that's different about annotated tag generation? Is my format assumptions wrong?
- Is the output of
git cat-fileequivalent to how I should be piecing this together? I am assuming so because the commit worked that way, but would be nice to confirm. - Git is open-source, right? Does anyone have a link for how they build the SHA-1 hash? Would be awesome to do this in a way that isn't guess and check.
Thanks in advance for the help, really struggling with this!
ANSWER: there is a space in gpgsig ONLY on commits