threads / patch / 25448

patchGIT-VERSION-GEN: make use of git describe --dirty

Subject: [PATCH] GIT-VERSION-GEN: make use of git describe --dirty

## tl;dr

2 messages between Oct 14, 2010 and Oct 14, 2010. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Mathias Lafledt· Oct 14, 2010, 16:17 UTC · lore

Currently, GIT-VERSION-GEN invokes the plumbing commands "git update-index" and "git diff-index" to determine if the working tree is dirty. It then appends "-dirty" to the version string returned by "git describe".

However, as of Git v1.6.6, "git describe" can be told to do all that with the "--dirty" option, saving us the plumbing.

Signed-off-by: Mathias Lafeldt <misfire@debugon.org>
---
 GIT-VERSION-GEN |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
Show changes to GIT-VERSION-GEN +2 −5
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index d441d88..73d5cf9 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -12,13 +12,10 @@ if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
 elif test -d .git -o -f .git &&
-	VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) &&
+	VN=$(git describe --match "v[0-9]*" --abbrev=4 --dirty 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 --)" ||
-		VN="$VN-dirty" ;;
+	v[0-9]*) : ;;
 	esac
 then
 	VN=$(echo "$VN" | sed -e 's/-/./g');
-- 
1.7.3.GIT
Mathias Lafeldt· Oct 14, 2010, 19:45 UTC · re: Mathias Lafledt · lore

[PATCH v2] GIT-VERSION-GEN: make use of git describe --dirty

Currently, GIT-VERSION-GEN invokes the plumbing commands "git update-index" and "git diff-index" to determine if the working tree is dirty. It then appends "-dirty" to the version string returned by "git describe".

However, as of Git v1.6.6, "git describe" can be told to do all that with the "--dirty" option, saving us the plumbing.

Signed-off-by: Mathias Lafeldt <misfire@debugon.org>
---
Corrected a typo in the "From:" field. Apart from that, the patch hasn't changed.
 GIT-VERSION-GEN |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
Show changes to GIT-VERSION-GEN +2 −5
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index d441d88..73d5cf9 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -12,13 +12,10 @@ if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
 elif test -d .git -o -f .git &&
-	VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null) &&
+	VN=$(git describe --match "v[0-9]*" --abbrev=4 --dirty 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 --)" ||
-		VN="$VN-dirty" ;;
+	v[0-9]*) : ;;
 	esac
 then
 	VN=$(echo "$VN" | sed -e 's/-/./g');
-- 
1.7.3.GIT

← back to recent threads