threads / patch / 3027

patchGIT-VERSION-GEN: detect dirty tree and mark the version accordingly.

Subject: [PATCH] GIT-VERSION-GEN: detect dirty tree and mark the version accordingly.

## tl;dr

One message between Jan 10, 2006 and Jan 10, 2006. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· Jan 10, 2006, 02:53 UTC · lore

If we are building from a working tree with local modifications, mark the version accordingly.

Deliberately uses '-' to prevent RPM from being built from such a tree.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * This is a useful precaution and should be safe, so planned to
   go into 1.1.1.
 GIT-VERSION-GEN |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
339b684aa42ac80964ef0d9049445dad7f83848c
Show changes to GIT-VERSION-GEN +8 −0
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index c878819..cb393b5 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -11,6 +11,14 @@ set)
 	;;
 esac
 
+dirty=$(sh -c 'git-diff-files --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)
-- 
1.1.0

← back to recent threads