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

[PATCH] For release tarballs, include the proper version

From
HAH. Peter Anvin <hpa@zytor.com>
Date
Jan 10, 2006, 02:07 UTC
Message-ID
<43C316C5.9060007@zytor.com>
In-Reply-To
<7vpsn1f1lb.fsf@assigned-by-dhcp.cox.net>

When producing a release tarball, include a "version" file, which GIT-VERSION-GEN can then use to do the right thing when building from a tarball.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 845b9dc..7763639 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,9 +1,15 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
+DEF_VER=v1.1.GIT
 
-VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT
-VN=$(expr "$VN" : v'\(.*\)')
+# First try git-describe, then see if there is a version file
+# (included in release tarballs), then default
+VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) ||
+VN=$(cat version) ||
+VN="$DEF_VER"
+
+VN=$(expr "$VN" : v*'\(.*\)')
 if test -r $GVF
 then
 	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
diff --git a/Makefile b/Makefile
index c9c15b5..fa0cd83 100644
--- a/Makefile
+++ b/Makefile
@@ -489,7 +489,9 @@ dist: git.spec git-tar-tree
 	./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
 	@mkdir -p $(GIT_TARNAME)
 	@cp git.spec $(GIT_TARNAME)
-	$(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
+	@echo $(GIT_VERSION) > $(GIT_TARNAME)/version
+	$(TAR) rf $(GIT_TARNAME).tar \
+		$(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
 	@rm -rf $(GIT_TARNAME)
 	gzip -f -9 $(GIT_TARNAME).tar
 
Previous: Junio C Hamano
Message 2 of 2 in “GIT-VERSION-GEN: allow overriding from Makefile”
  1. GIT-VERSION-GEN: allow overriding from MakefileJunio C Hamano, Jan 9, 2006
  2. For release tarballs, include the proper versionH. Peter Anvin, Jan 10, 2006

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.