Re: checking sha1's of files
- From
Jeff King <peff@peff.net>
- Date
- Feb 8, 2009, 11:13 UTC
- Message-ID
- <20090208111343.GC14359@coredump.intra.peff.net>
- In-Reply-To
- <81bfc67a0902080253x5082201co7da3319b8237f5a0@mail.gmail.com>
On Sun, Feb 08, 2009 at 05:53:31AM -0500, Caleb Cushing wrote:
Show 10 quoted lines
> > but without knowing what kind of hash they use, I cannot tell you if you > > can reuse some part of git to compute their hash without using their tools > > (it also is unclear why you are not using their tool to compute their hash > > and instead are expecting git to know about the specific hash function > > used by them). > > I think you misunderstand. I'm not trying to use git to compute their > hash, I'm trying to replace their hash with git. Once I've figured out > how to validate the git hash with 'emerge' (said tool) I will be > removing their hash's.
I'm still not sure I entirely understand what you are trying to do, but these building blocks may help.
You can see git's idea of the hash of a file in history (or in the index) by asking rev-parse:
# hash of 'Makefile' in the most recent commit on the current branch $ git rev-parse HEAD:Makefile 27b9569746179e68c635bdaab8e57395f63faf01
# hash of 'Makefile' in the index $ git rev-parse :Makefile 27b9569746179e68c635bdaab8e57395f63faf01
# hash of 'Makefile' in some arbitrary revision $ git rev-parse v1.5.1:Makefile b159ffd0ae49c28725de6549132e0ad3a3b69d20
And you can compute the git blob hash of any file use git hash-object:
$ git hash-object --stdin < Makefile 27b9569746179e68c635bdaab8e57395f63faf01
So if I understand you correctly, you would use the former when generating your manifests from a revision, and the latter when verifying the contents of the filesystem against those manifests.
-Peff