builtin-mv: fix use of uninitialized memory.
[thirdparty/git.git] / GIT-VERSION-GEN
CommitLineData
9b88fcef
JH
1#!/bin/sh
2
3GVF=GIT-VERSION-FILE
5a716826 4DEF_VER=v1.4.2.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
1100ac81 8if VN=$(git describe --abbrev=4 HEAD 2>/dev/null); then
374dfaa2 9 VN=$(echo "$VN" | sed -e 's/-/./g');
0b8b051c
JH
10elif test -f version
11then
374dfaa2 12 VN=$(cat version) || VN="$DEF_VER"
0b8b051c
JH
13else
14 VN="$DEF_VER"
374dfaa2 15fi
181129d2
PA
16
17VN=$(expr "$VN" : v*'\(.*\)')
eb858c60 18
1100ac81 19dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
eb858c60
JH
20case "$dirty" in
21'')
22 ;;
23*)
24 VN="$VN-dirty" ;;
25esac
26
9b88fcef
JH
27if test -r $GVF
28then
29 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
30else
31 VC=unset
32fi
33test "$VN" = "$VC" || {
34 echo >&2 "GIT_VERSION = $VN"
35 echo "GIT_VERSION = $VN" >$GVF
36}
37
38