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

Re: Possible kinder GIT-VERSION-GEN?

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 4, 2008, 21:59 UTC
Message-ID
<7vve54ids2.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<18343.30080.67524.3427@lisa.zopyra.com>
Bill Lear <rael@zopyra.com> writes:
> I have my home directory under git control, and I have a build
> directory (not tracked by git) under my home directory into which I
> untar files and then in which I build things, including git.

Let me make sure I understand you by rephrasing. You are extracting git tarball as an untracked subdirectory in an unrelated project, and GIT-VERSION-GEN misbehaves. One such misbehaviour is that it adds -dirty.

And I think you are right. The -dirty suffix should be relative to the output of "git describe". Version string derived from any other codepath should not get the suffix, simply because we do not even know if it is dirty. In fact, we should not even attempt to run that diff-index to figure out if it is dirty.

---
 GIT-VERSION-GEN |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 38a3273..127c428 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -15,7 +15,9 @@ elif test -d .git &&
 	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
-	v[0-9]*) : happy ;;
+	v[0-9]*)
+		dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) &&
+		VN="$VN-dirty" ;;
 	esac
 then
 	VN=$(echo "$VN" | sed -e 's/-/./g');
@@ -25,14 +27,6 @@ fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
 
-dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
-case "$dirty" in
-'')
-	;;
-*)
-	VN="$VN-dirty" ;;
-esac
-
 if test -r $GVF
 then
 	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
Previous: Bill LearNext: Bill Lear
Message 2 of 3 in “Possible kinder GIT-VERSION-GEN?”
  1. Bill LearFeb 4, 2008
  2. Junio C HamanoFeb 4, 2008
  3. Bill LearFeb 4, 2008

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.