GIT 1.5.2.2
[git/git.git] / GIT-VERSION-GEN
CommitLineData
9b88fcef
JH
1#!/bin/sh
2
3GVF=GIT-VERSION-FILE
c7c84859 4DEF_VER=v1.5.2.2.GIT
9b88fcef 5
c96c2909
JH
6LF='
7'
8
204d4092
JH
9# First see if there is a version file (included in release tarballs),
10# then try git-describe, then default.
11if test -f version
0b8b051c 12then
374dfaa2 13 VN=$(cat version) || VN="$DEF_VER"
204d4092
JH
14elif test -d .git &&
15 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
16 case "$VN" in
17 *$LF*) (exit 1) ;;
18 v[0-9]*) : happy ;;
19 esac
20then
21 VN=$(echo "$VN" | sed -e 's/-/./g');
0b8b051c
JH
22else
23 VN="$DEF_VER"
374dfaa2 24fi
181129d2
PA
25
26VN=$(expr "$VN" : v*'\(.*\)')
eb858c60 27
1100ac81 28dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
eb858c60
JH
29case "$dirty" in
30'')
31 ;;
32*)
33 VN="$VN-dirty" ;;
34esac
35
9b88fcef
JH
36if test -r $GVF
37then
38 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
39else
40 VC=unset
41fi
42test "$VN" = "$VC" || {
43 echo >&2 "GIT_VERSION = $VN"
44 echo "GIT_VERSION = $VN" >$GVF
45}
46
47