GIT-VERSION-GENon commit Format tweaks for asciidoc. (b0d08a5)
   1#!/bin/sh
   2
   3GVF=GIT-VERSION-FILE
   4DEF_VER=v1.2.GIT
   5
   6# First try git-describe, then see if there is a version file
   7# (included in release tarballs), then default
   8if VN=$(git-describe --abbrev=4 HEAD 2>/dev/null); then
   9        VN=$(echo "$VN" | sed -e 's/-/./g');
  10elif test -f version
  11then
  12        VN=$(cat version) || VN="$DEF_VER"
  13else
  14        VN="$DEF_VER"
  15fi
  16
  17VN=$(expr "$VN" : v*'\(.*\)')
  18
  19dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty=
  20case "$dirty" in
  21'')
  22        ;;
  23*)
  24        VN="$VN-dirty" ;;
  25esac
  26
  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