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

Re: Trouble building newer git with older

From
Junio C Hamano <junkio@cox.net>
Date
Aug 8, 2006, 20:11 UTC
Message-ID
<7v7j1jvvh7.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060808184716.GC4546@us.ibm.com>
Nishanth Aravamudan <nacc@us.ibm.com> writes:
Show 6 quoted lines
> This is because GIT-VERSION-GEN attempts to invoke `git describe` but
> describe is not a valid parameter to the current version of git. This is
> not treated as a failure case, though, as output is stored in VN.
> Perhaps the return code of `git describe` should also be checked? Or am
> I just not supposed to upgrade from this old of a version of git via
> git?
No, it was broken when this patch was applied.
        commit 1100ac81a90b03e0c037a286569a340decf7489b
        Author: Sean <seanlkml@sympatico.ca>
        Date:   Mon May 22 00:39:52 2006 -0400
Luckily, my copy of GNU interactive tools, when invoked like this:
	git describe --abbrev=4 HEAD 2>/dev/null
exits with an error code 1, so the existing code already catches it.
How about this patch?
-- >8 --
GIT-VERSION-GEN: adjust for ancient git

When an ancient "git" that does not understand "describe" command is on the $PATH, "git describe" emitted a Usage message without exiting non-zero status (which is a mistake we cannot fix retroactively). Catch this case to make sure we do not try using phoney multi-line string as a version number.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 1ce217d..14923c9 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -3,9 +3,17 @@ #!/bin/sh
 GVF=GIT-VERSION-FILE
 DEF_VER=v1.4.2.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); then
+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
 then
Previous: Nishanth AravamudanNext: Nishanth Aravamudan
Message 2 of 3 in “Trouble building newer git with older”
  1. Nishanth AravamudanAug 8, 2006
  2. Junio C HamanoAug 8, 2006
  3. Nishanth AravamudanAug 8, 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.