Update git revision script.

This commit is contained in:
Dave Davenport 2016-04-10 13:22:49 +02:00
parent a69754abff
commit 93362d63f2
1 changed files with 4 additions and 3 deletions

View File

@ -2,18 +2,19 @@
DIR=$1
FILE=$2
GIT=$(which git)
if [ -d "${DIR}/.git/" ]
if [ -d "${DIR}/.git/" ] && [ -n "${GIT}" ]
then
echo -n "#define GIT_VERSION \"" > ${FILE}.tmp
REV="$(git describe --tags --always --dirty) ($(git describe --tags --always --all | sed -e 's:heads/::'))"
REV="$(${GIT} describe --tags --always --dirty) ($(${GIT} describe --tags --always --all | sed -e 's:heads/::'))"
echo -n "${REV}" >> ${FILE}.tmp
echo "\"" >> ${FILE}.tmp
else
echo "#undef GIT_VERSION" > ${FILE}.tmp
fi
if ! diff ${FILE}.tmp ${FILE} > /dev/null
if [ ! -f ${FILE} ] || ! diff ${FILE}.tmp ${FILE} > /dev/null
then
mv ${FILE}.tmp ${FILE}
else