Windows ANSI - hook write()
[git/mingw/4msysgit/peterh.git] / GIT-VERSION-GEN
blobf221447478aea8628c0ab6d098338f7e8630201e
1 #!/bin/sh
3 GVF=GIT-VERSION-FILE
4 DEF_VER=v1.5.6.GIT
6 LF='
9 # First see if there is a version file (included in release tarballs),
10 # then try git-describe, then default.
11 if test -f version
12 then
13 VN=$(cat version) || VN="$DEF_VER"
14 elif test -d .git -o -f .git &&
15 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
16 case "$VN" in
17 *$LF*) (exit 1) ;;
18 v[0-9]*)
19 test -z "$(git diff-index --name-only HEAD)" ||
20 VN="$VN-dirty" ;;
21 esac
22 then
23 VN=$(echo "$VN" | sed -e 's/-/./g');
24 else
25 VN="$DEF_VER"
28 VN=$(expr "$VN" : v*'\(.*\)')
30 if test -r $GVF
31 then
32 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
33 else
34 VC=unset
36 test "$VN" = "$VC" || {
37 echo >&2 "GIT_VERSION = $VN"
38 echo "GIT_VERSION = $VN" >$GVF