We don't use `git-foo` since git 1.6. HEAD is the default of `git describe`. Also, deal with a bunch of shellcheck warnings. Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- GIT-VERSION-GEN | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 29d634a30b..6dd7683ee7 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -7,7 +7,7 @@ LF=' ' describe () { - VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) || return 1 + VN=$(git describe --match "v[0-9]*" 2>/dev/null) || return 1 case "$VN" in *$LF*) return 1 @@ -22,26 +22,24 @@ describe () { } # First see if there is a version file (included in release tarballs), -# then try git-describe, then default. +# then try `git describe`, then default. if test -f version then VN=$(cat version) || VN="$DEF_VER" -elif test -d ${GIT_DIR:-.git} -o -f .git && describe +elif test -d "${GIT_DIR:-.git}" -o -f .git && describe then - VN=$(echo "$VN" | sed -e 's/-/./g'); + VN=$(echo "$VN" | sed -e 's/-/./g') else VN="$DEF_VER" fi -VN=$(expr "$VN" : v*'\(.*\)') +VN=$(expr "$VN" : 'v*\(.*\)') if test -r $GVF then VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) else - VC=unset + VC='unset' fi -test "$VN" = "$VC" || { - echo >&2 "GIT_VERSION = $VN" - echo "GIT_VERSION = $VN" >$GVF -} +test "$VN" = "$VC" && exit +echo "GIT_VERSION = $VN" | tee $GVF >&2 -- 2.40.0+fc1