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

Re: Add a "git-describe" command

From
Linus Torvalds <torvalds@osdl.org>
Date
Dec 24, 2005, 22:13 UTC
Message-ID
<Pine.LNX.4.64.0512241409300.14098@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.64.0512241339120.14098@g5.osdl.org>
On Sat, 24 Dec 2005, Linus Torvalds wrote:
Show 6 quoted lines
> 
> This is useful for two things:
> 
>  - automatic version naming in Makefiles, for example. We could use it in 
>    git itself: when doing "git --version", we could use this to give a 
>    much more useful description of exactly what version was installed.

This trivial patch fails to do that correctly, but maybe somebody could fix it.

The problem is not that it generates GIT_VERSION wrong. The problem is 
two-fold:
 - it should notice when "git-describe" doesn't exist, and fall back on 
   the old less-than-descriptive behaviour
 - it doesn't do dependencies correctly (ie it should now make "git" 
   depend on the version number, but it doesn't, so it doesn't re-build 
   git after a commit/pull)
but at least it shows the _idea_ of using git-describe.
With this I get
	[torvalds@g5 git]$ git --version
	git version v1.0.4-g6e9961d6

which I think is better than "1.0.GIT" which doesn't say anything about what the _actual_ version was.

(Ignore the particular SHA1 hash - it has my local commit that you can't re-create that just created that git-describe thing. You'll get your own version number).

		Linus
---
diff --git a/Makefile b/Makefile
index 47e7898..2e5c569 100644
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,7 @@ all:
 # Define USE_STDEV below if you want git to care about the underlying device
 # change being considered an inode change from the update-cache perspective.
 
-GIT_VERSION = 1.0.GIT
+GIT_VERSION = $(shell git-describe HEAD | sed 's:refs/tags/::')
 
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
Previous: Linus TorvaldsNext: M_
Message 2 of 14 in “Add a "git-describe" command”
  1. Linus TorvaldsDec 24, 2005
  2. Linus TorvaldsDec 24, 2005
  3. M_Dec 25, 2005
  4. Junio C HamanoDec 28, 2005
  5. Johannes SchindelinDec 28, 2005
  6. 1/6 git-describe: really prefer tags only.Junio C Hamano, Dec 28, 2005
  7. 2/6 git-describe: use find_unique_abbrev()Junio C Hamano, Dec 28, 2005
  8. 3/6 git-describe: --tags and --abbrevJunio C Hamano, Dec 28, 2005
  9. 4/6 git-describe: still prefer annotated tag under --all and --tagsJunio C Hamano, Dec 28, 2005
  10. 5/6 git-describe: documentation.Junio C Hamano, Dec 28, 2005
  11. 6/6 Makefile: use git-describe to mark the git version.Junio C Hamano, Dec 28, 2005
  12. Junio C HamanoDec 25, 2005
  13. Linus TorvaldsDec 25, 2005
  14. Junio C HamanoDec 25, 2005

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.