2005-12-27 15:40:17 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
GVF=GIT-VERSION-FILE
|
2023-11-02 02:09:48 -06:00
|
|
|
DEF_VER=v2.43.0-rc0
|
2005-12-27 15:40:17 -07:00
|
|
|
|
2006-08-08 14:11:16 -06:00
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2007-02-14 12:33:04 -07:00
|
|
|
# First see if there is a version file (included in release tarballs),
|
|
|
|
# then try git-describe, then default.
|
|
|
|
if test -f version
|
2006-03-02 15:38:44 -07:00
|
|
|
then
|
2006-01-26 09:39:27 -07:00
|
|
|
VN=$(cat version) || VN="$DEF_VER"
|
2013-06-15 17:01:11 -06:00
|
|
|
elif test -d ${GIT_DIR:-.git} -o -f .git &&
|
2016-12-04 13:45:59 -07:00
|
|
|
VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
|
2007-02-14 12:33:04 -07:00
|
|
|
case "$VN" in
|
|
|
|
*$LF*) (exit 1) ;;
|
2008-02-16 23:44:31 -07:00
|
|
|
v[0-9]*)
|
2008-08-08 14:31:27 -06:00
|
|
|
git update-index -q --refresh
|
2008-06-28 11:13:29 -06:00
|
|
|
test -z "$(git diff-index --name-only HEAD --)" ||
|
2008-02-23 12:31:04 -07:00
|
|
|
VN="$VN-dirty" ;;
|
2007-02-14 12:33:04 -07:00
|
|
|
esac
|
|
|
|
then
|
|
|
|
VN=$(echo "$VN" | sed -e 's/-/./g');
|
2006-03-02 15:38:44 -07:00
|
|
|
else
|
|
|
|
VN="$DEF_VER"
|
2006-01-26 09:39:27 -07:00
|
|
|
fi
|
2006-01-09 19:07:01 -07:00
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
2006-01-09 15:25:10 -07:00
|
|
|
|
2005-12-27 15:40:17 -07:00
|
|
|
if test -r $GVF
|
|
|
|
then
|
|
|
|
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
|
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
|
|
|
test "$VN" = "$VC" || {
|
|
|
|
echo >&2 "GIT_VERSION = $VN"
|
|
|
|
echo "GIT_VERSION = $VN" >$GVF
|
|
|
|
}
|