Use git for version number too
authorDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 21 Aug 2008 00:11:22 +0000 (20:11 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Thu, 21 Aug 2008 00:11:22 +0000 (20:11 -0400)
Date: Tue, 19 Aug 2008 18:57:17 +0100
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
version.sh

index d7988bf..209b7d1 100644 (file)
@@ -8,7 +8,23 @@
  
 v="Btrfs v0.16"
 
-which hg > /dev/null
+which git &> /dev/null
+if [ $? == 0 -a -d .git ]; then
+    if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+        if tag=`git describe --tags 2>/dev/null`; then
+            v="$tag"
+        fi
+
+        # Are there uncommitted changes?
+        git update-index --refresh --unmerged > /dev/null
+        if git diff-index --name-only HEAD | grep -v "^scripts/package" \
+            | read dummy; then
+            v="$v"-dirty
+        fi
+    fi
+fi
+
+which hg &> /dev/null
 if [ $? == 0 -a -d .hg ]; then
        last=$(hg tags | grep -m1 -o '^v[0-9.]\+')