Re: checking sha1's of files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Feb 08, 2009 at 07:22:31AM -0500, Caleb Cushing wrote:

> >  $ 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux