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