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
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 17, 2007, 06:10 UTC
Message-ID
<20070217061016.GA27813@spearce.org>
In-Reply-To
<3c6c07c20702160823j316c52f4pe4cf5ca8a882e194@mail.gmail.com>
Mike Coleman <tutufan@gmail.com> wrote:
Show 12 quoted lines
> Here's a suggestion for a git feature, if git doesn't already have it.
> Since git generally doesn't use RCS-style keyword cookies (like
> "$Id$"), it'd be nice to have some other way to identify an installed
> file.  Perhaps you'd want to know exactly what rev a user is running,
> for example.
> 
> 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.  (I
> can't recall exactly how git's blob SHA1's are computed--maybe this
> isn't feasible.)

Rather than embedding something like "$Id$" on a per-file basis use the output of git-describe in your build process to insert the string into your executable file(s), and then provide a way to let the user extract it, or insert it with a unique enough pattern that you can grep for it in the output of `strings`.

This is what git does itself. We replace GIT_VERSION in git.c with the output of git-describe during compile time (C preprocessor macro). The value can be printed by the user with `git version`. We also embed it into some Perl scripts.

git-gui does the same thing, but is a Tcl/Tk script.
-- 
Shawn.
Previous: Linus TorvaldsNext: Andy Parkins
Message 5 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.