Make "git clone" pack-fetching download statistics better
[git/dscho.git] / GIT-VERSION-GEN
blob72201be57c633259e65b435f8623a80e4cdc3e88
1 #!/bin/sh
3 GVF=GIT-VERSION-FILE
4 DEF_VER=v1.1.GIT
6 # First try git-describe, then see if there is a version file
7 # (included in release tarballs), then default
8 if VN=$(git-describe --abbrev=4 HEAD 2>/dev/null); then
9 VN=$(echo "$VN" | sed -e 's/-/./g');
10 else
11 VN=$(cat version) || VN="$DEF_VER"
14 VN=$(expr "$VN" : v*'\(.*\)')
16 dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty=
17 case "$dirty" in
18 '')
21 VN="$VN-dirty" ;;
22 esac
24 if test -r $GVF
25 then
26 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
27 else
28 VC=unset
30 test "$VN" = "$VC" || {
31 echo >&2 "GIT_VERSION = $VN"
32 echo "GIT_VERSION = $VN" >$GVF