autoconf: update curses.m4
[openafs.git] / build-tools / git-version
index b8c6802..ff55b4a 100755 (executable)
@@ -1,20 +1,31 @@
 #!/bin/sh
 
-version_file=$1
+srcdir=$1
+fallback=$2
 
-if [ -f $version_file ] ; then
-  git_version=`cat $version_file`
+if [ "x$fallback" = "x" ]; then
+  fallback=UNKNOWN
+fi
+
+if [ -f $srcdir/.version ] ; then
+  git_version=`cat $srcdir/.version`
 else
   if which git > /dev/null; then
+    cd $srcdir
     git_version=`git describe --abbrev=4 HEAD 2>/dev/null`
-
-    # Is the working tree dirty?
-    if ! git diff-index --quiet --cached HEAD --ignore-submodules || \
-       ! git diff-files --quiet --ignore-submodules ; then
-      git_version="$git_version-dirty"
+    if [ $? = 0 ]; then
+      # Is the working tree dirty?
+      if git diff-index --quiet --cached HEAD && \
+         git diff-files --quiet ; then
+        :
+      else
+        git_version="$git_version-dirty"
+      fi
+    else
+      git_version=$fallback
     fi
   else
-    git_version=UNKNOWN
+    git_version=$fallback
   fi
 fi