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

[PATCH] To make GIT-VERSION-FILE, search for git more widely

From
MAMatthias Andree <matthias.andree@gmx.de>
Date
Apr 26, 2009, 11:59 UTC
Message-ID
<1240747190-12005-1-git-send-email-matthias.andree@gmx.de>
Problem: when git is installed into /usr/local/bin, running 'sudo make
install' won't find git in $PATH (because sudo strips PATH, for instance
on openSUSE 11.1, and doesn't include /usr/local/whatever).

This causes GIT-VERSION-FILE to not find git for git describe, and fall back to DEF_VER.

This in turn causes rebuilds of major parts of the system.

This patch passes GIT through to the shell script, and additionally looks for the current version and in ${prefix}/bin.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
---
 GIT-VERSION-GEN |    7 ++++---
 Makefile        |    6 +++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 97fc1e0..22661c0 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -2,6 +2,7 @@
 
 GVF=GIT-VERSION-FILE
 DEF_VER=v1.6.2.GIT
+test -x "$GIT" || GIT=git
 
 LF='
 '
@@ -12,12 +13,12 @@ if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
 elif test -d .git -o -f .git &&
-	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+	VN=$(${GIT} describe --abbrev=4 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
 	v[0-9]*)
-		git update-index -q --refresh
-		test -z "$(git diff-index --name-only HEAD --)" ||
+		${GIT} update-index -q --refresh
+		test -z "$(${GIT} diff-index --name-only HEAD --)" ||
 		VN="$VN-dirty" ;;
 	esac
 then
diff --git a/Makefile b/Makefile
index 5c8e83a..408228e 100644
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,11 @@ all::
 # away (some NTFS drivers seem to zero the contents in that scenario).
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
-	@$(SHELL_PATH) ./GIT-VERSION-GEN
+	@{ GIT=./git$X ; type $$GIT >/dev/null 2>&1 ; } \
+	    || { GIT=$(prefix)/bin/git$X ; type $$GIT >/dev/null 2>&1 ; }\
+	    || GIT=git ; \
+	    export GIT ; \
+	    $(SHELL_PATH) ./GIT-VERSION-GEN
 -include GIT-VERSION-FILE
 
 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
-- 
1.6.3.rc2.9.g97ad0
Message 1 of 1 in “To make GIT-VERSION-FILE, search for git more widely”
  1. To make GIT-VERSION-FILE, search for git more widelyMatthias Andree, Apr 26, 2009

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.