Merge branch 'ma/asciidoctor-more-fixes'
[git/git.git] / GIT-VERSION-GEN
CommitLineData
9b88fcef
JH
1#!/bin/sh
2
3GVF=GIT-VERSION-FILE
745f6812 4DEF_VER=v2.23.GIT
9b88fcef 5
c96c2909
JH
6LF='
7'
8
204d4092
JH
9# First see if there is a version file (included in release tarballs),
10# then try git-describe, then default.
11if test -f version
0b8b051c 12then
374dfaa2 13 VN=$(cat version) || VN="$DEF_VER"
05a95063 14elif test -d ${GIT_DIR:-.git} -o -f .git &&
a7659747 15 VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
204d4092
JH
16 case "$VN" in
17 *$LF*) (exit 1) ;;
e5fc9a0a 18 v[0-9]*)
b13d4409 19 git update-index -q --refresh
935e247e 20 test -z "$(git diff-index --name-only HEAD --)" ||
31e0b2ca 21 VN="$VN-dirty" ;;
204d4092
JH
22 esac
23then
24 VN=$(echo "$VN" | sed -e 's/-/./g');
0b8b051c
JH
25else
26 VN="$DEF_VER"
374dfaa2 27fi
181129d2
PA
28
29VN=$(expr "$VN" : v*'\(.*\)')
eb858c60 30
9b88fcef
JH
31if test -r $GVF
32then
33 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
34else
35 VC=unset
36fi
37test "$VN" = "$VC" || {
38 echo >&2 "GIT_VERSION = $VN"
39 echo "GIT_VERSION = $VN" >$GVF
40}