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

`git describe` in an export-subst format string?

From
JGJohn Gallagher <johnkgallagher@gmail.com>
Date
Apr 28, 2013, 18:02 UTC
Message-ID
<CAFoDJR8RQExLwXcrViAJpWgvq+wBopY-Wq1keHxVqB3QwtAz4A@mail.gmail.com>

I originally posted this as a question about getting `git log` to output the same thing that `git describe` does to the git-users mailing list, and was directed here. The actual thing I want to do is something like this:

  static const char *project_version = "$Format:...$";

where "..." is something that `git archive` will replace with the output of `git describe`, given the file has the export-subst property, possibly with arguments to git describe (--tags, --all, etc.). In a normal build I can do this with the build system just calling git directly, but if I'm archiving a tarball off there doesn't seem to be a way to do this (other than manually replacing the format string myself as some secondary step).

Does this seem like a reasonable thing to do, or am I overlooking a better alternative? If this is something that seems reasonable, I wouldn't mind taking a stab at implementing it. If that sounds okay, could make sure I'm pointed in the right direction? E.g., should `git log --format=...` have options that spit out `git describe` strings since that's what export-subst currently uses, or should there be a separate $Format:...$ option that runs git describe?

Thanks, John

Next: Junio C Hamano
Message 1 of 3 in “`git describe` in an export-subst format string?”
  1. John GallagherApr 28, 2013
  2. Junio C HamanoApr 28, 2013
  3. Junio C HamanoApr 28, 2013

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.