]> git.ipfire.org Git - thirdparty/git.git/blame - GIT-VERSION-GEN
Use symbolic name SHORT_NAME_AMBIGUOUS as error return value
[thirdparty/git.git] / GIT-VERSION-GEN
CommitLineData
9b88fcef
JH
1#!/bin/sh
2
3GVF=GIT-VERSION-FILE
181129d2 4DEF_VER=v1.1.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
5c7d3c95 8VN=$(git-describe --abbrev=4 HEAD 2>/dev/null | sed -e 's/-/./g') ||
181129d2
PA
9VN=$(cat version) ||
10VN="$DEF_VER"
11
12VN=$(expr "$VN" : v*'\(.*\)')
eb858c60
JH
13
14dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty=
15case "$dirty" in
16'')
17 ;;
18*)
19 VN="$VN-dirty" ;;
20esac
21
9b88fcef
JH
22if test -r $GVF
23then
24 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
25else
26 VC=unset
27fi
28test "$VN" = "$VC" || {
29 echo >&2 "GIT_VERSION = $VN"
30 echo "GIT_VERSION = $VN" >$GVF
31}
32
33