X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=GIT-VERSION-GEN;h=1056b7c817f8578348120f64ad7047754bf688df;hb=4d569a2c422a9655390e7d33cad0bab88379f13d;hp=845b9dce6eaab80d011370f701c254a051027cc2;hpb=5a2282de13c4da13f979185e652c8a08e2481fd1;p=git.git diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 845b9dce..1056b7c8 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,9 +1,26 @@ #!/bin/sh GVF=GIT-VERSION-FILE +DEF_VER=v1.2.GIT + +# First try git-describe, then see if there is a version file +# (included in release tarballs), then default +if VN=$(git-describe --abbrev=4 HEAD 2>/dev/null); then + VN=$(echo "$VN" | sed -e 's/-/./g'); +else + VN=$(cat version) || VN="$DEF_VER" +fi + +VN=$(expr "$VN" : v*'\(.*\)') + +dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty= +case "$dirty" in +'') + ;; +*) + VN="$VN-dirty" ;; +esac -VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) || VN=v1.0.GIT -VN=$(expr "$VN" : v'\(.*\)') if test -r $GVF then VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)