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

Re: suggested feature: someone mails me a blob, git please tell me what it is

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Feb 16, 2007, 17:14 UTC
Message-ID
<vpqr6sq58j8.fsf@olympe.imag.fr>
In-Reply-To
<3c6c07c20702160823j316c52f4pe4cf5ca8a882e194@mail.gmail.com>
"Mike Coleman" <tutufan@gmail.com> writes:
> It seems like it should be fairly easy, given a blob (the file), for
> git to describe what it knows about it.  For example, it could provide
> a list of commits that it's a part of, etc.  It'd be *really* nice if
> only the output of the sha1sum command on the blob were needed. 

"git cat-file -p" does almost this : given the sha1sum for a blob, it will give the header and the content of the blob ...

> (I can't recall exactly how git's blob SHA1's are computed--maybe
> this isn't feasible.)

... but this is where it doesn't work : http://www.kernel.org/pub/software/scm/git/docs/v1.5.0/git.html#Discussion explains that the sha1sum used by git is the one of the blob _plus_ its header, so it's not the one you get with "sha1sum file".

But it should be possible to recompute the git sha1sum by recomputing the magic formula sha1sum(<ascii type without space> + <space> + <ascii decimal size> + <byte\0> + <binary object data>).

-- 
Matthieu
Previous: Nicolas PitreNext: Linus Torvalds
Message 3 of 6 in “suggested feature: someone mails me a blob, git please tell me what it is”
  1. Mike ColemanFeb 16, 2007
  2. Nicolas PitreFeb 16, 2007
  3. Matthieu MoyFeb 16, 2007
  4. Linus TorvaldsFeb 16, 2007
  5. Shawn O. PearceFeb 17, 2007
  6. Andy ParkinsFeb 17, 2007

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.