Re: checking sha1's of files
- From
Jeff King <peff@peff.net>
- Date
- Feb 8, 2009, 12:27 UTC
- Message-ID
- <20090208122731.GA24442@coredump.intra.peff.net>
- In-Reply-To
- <81bfc67a0902080422s7f12d86ft5196c184c06385f9@mail.gmail.com>
On Sun, Feb 08, 2009 at 07:22:31AM -0500, Caleb Cushing wrote:
Show 6 quoted lines
> > $ git hash-object --stdin < Makefile > > 27b9569746179e68c635bdaab8e57395f63faf01 > > is there anyway built in way to do that and check to see if the hash > matches HEAD? (before I go and write a string comparison so that it > does)
If you want to know whether a file matches HEAD, just do:
git diff --quiet HEAD -- $LIST_OF_FILES
which will return '0' for no changes or '1' if there are changes.
Which really has nothing to do with hashes at all (though git will use them internally to avoid actually running a textual diff at all). I was assuming that you didn't necessarily _have_ the git repository at verification time. So the hash becomes an easy way of saying "this is what the file _should_ look like".
But again, I'm not sure I really understand the workflow you're trying to perform.
-Peff