git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Caleb CushingNext: Caleb Cushing
Message 4 of 7 in “checking sha1's of files”
  1. Caleb CushingFeb 8, 2009
  2. Junio C HamanoFeb 8, 2009
  3. Caleb CushingFeb 8, 2009
  4. Jeff KingFeb 8, 2009
  5. Caleb CushingFeb 8, 2009
  6. Jeff KingFeb 8, 2009
  7. Caleb CushingFeb 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.