2010-06-26 19:35:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-06-29 21:45:36 +01:00
|
|
|
srcdir=$1
|
|
|
|
fallback=$2
|
2010-06-26 19:35:18 +01:00
|
|
|
|
2010-06-29 21:45:36 +01:00
|
|
|
if [ "x$fallback" = "x" ]; then
|
|
|
|
fallback=UNKNOWN
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $srcdir/.version ] ; then
|
|
|
|
git_version=`cat $srcdir/.version`
|
2010-06-26 19:35:18 +01:00
|
|
|
else
|
|
|
|
if which git > /dev/null; then
|
2010-06-29 21:45:36 +01:00
|
|
|
cd $srcdir
|
2010-06-26 19:35:18 +01:00
|
|
|
git_version=`git describe --abbrev=4 HEAD 2>/dev/null`
|
2010-06-29 21:45:36 +01:00
|
|
|
if [ $? = 0 ]; then
|
|
|
|
# Is the working tree dirty?
|
2011-01-08 01:48:18 +00:00
|
|
|
if git diff-index --quiet --cached HEAD && \
|
|
|
|
git diff-files --quiet ; then
|
2010-06-29 21:45:36 +01:00
|
|
|
:
|
|
|
|
else
|
|
|
|
git_version="$git_version-dirty"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
git_version=$fallback
|
2010-06-26 19:35:18 +01:00
|
|
|
fi
|
|
|
|
else
|
2010-06-29 21:45:36 +01:00
|
|
|
git_version=$fallback
|
2010-06-26 19:35:18 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$git_version" | sed -e 's/openafs-[^-]*-//' -e 's/_/./g' | tr -d '\012'
|