]> git.ipfire.org Git - thirdparty/git.git/blame - GIT-VERSION-GEN
Fix "test: unexpected operator" on bsd
[thirdparty/git.git] / GIT-VERSION-GEN
CommitLineData
9b88fcef
JH
1#!/bin/sh
2
3GVF=GIT-VERSION-FILE
181129d2 4DEF_VER=v1.1.GIT
9b88fcef 5
181129d2
PA
6# First try git-describe, then see if there is a version file
7# (included in release tarballs), then default
374dfaa2
UZ
8if VN=$(git-describe --abbrev=4 HEAD 2>/dev/null); then
9 VN=$(echo "$VN" | sed -e 's/-/./g');
10else
11 VN=$(cat version) || VN="$DEF_VER"
12fi
181129d2
PA
13
14VN=$(expr "$VN" : v*'\(.*\)')
eb858c60
JH
15
16dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty=
17case "$dirty" in
18'')
19 ;;
20*)
21 VN="$VN-dirty" ;;
22esac
23
9b88fcef
JH
24if test -r $GVF
25then
26 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
27else
28 VC=unset
29fi
30test "$VN" = "$VC" || {
31 echo >&2 "GIT_VERSION = $VN"
32 echo "GIT_VERSION = $VN" >$GVF
33}
34
35