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

Re: bug: build from tarball uses git-describe

From
Junio C Hamano <junkio@cox.net>
Date
Feb 14, 2007, 19:26 UTC
Message-ID
<7vlkj0o814.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0702140206550.22628@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 9 quoted lines
> It checks if the file "version" exists, and takes the contents of that as 
> version, otherwise $DEF_VER.
>
>> After all fresh tarball is how we build rpm packages and we do
>> not have .git in that build environment, so I am quite puzzled.
>
> Yes, the idea was: if there is no .git, do not even bother checking the 
> output of git-describe (it might find a .git directory in a parent 
> directory, after all).

Ok, then let's do this. Our tarballs do have version file, and if the upperlevel Makefile wants to set a different version it can drop 'version' file before descending into us.

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index febacd2..6abde8d 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -6,18 +6,19 @@ DEF_VER=v1.5.0.GIT
 LF='
 '
 
-# First try git-describe, then see if there is a version file
-# (included in release tarballs), then default
-if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
-   case "$VN" in
-   *$LF*) (exit 1) ;;
-   v[0-9]*) : happy ;;
-   esac
-then
-	VN=$(echo "$VN" | sed -e 's/-/./g');
-elif test -f version
+# First see if there is a version file (included in release tarballs),
+# then try git-describe, then default.
+if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
+elif test -d .git &&
+	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+	case "$VN" in
+	*$LF*) (exit 1) ;;
+	v[0-9]*) : happy ;;
+	esac
+then
+	VN=$(echo "$VN" | sed -e 's/-/./g');
 else
 	VN="$DEF_VER"
 fi
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 5 of 6 in “bug: build from tarball uses git-describe”
  1. Han-Wen NienhuysFeb 13, 2007
  2. Johannes SchindelinFeb 14, 2007
  3. Junio C HamanoFeb 14, 2007
  4. Johannes SchindelinFeb 14, 2007
  5. Junio C HamanoFeb 14, 2007
  6. Johannes SchindelinFeb 14, 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.