summaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-03-12 14:00:19 +0100
committerDave Davenport <qball@gmpclient.org>2016-03-12 14:00:19 +0100
commit545c423b61e3852f23577ab2120a7312a7b088d5 (patch)
tree4a99c9614a469f2f72cb96bdc60dbbae7c1f65b1 /script
parentabe44475fc0d119d392d2fee7d407ef6e62bbf81 (diff)
Tried to fix strlen on NULL
Diffstat (limited to 'script')
-rwxr-xr-xscript/get_git_rev.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/script/get_git_rev.sh b/script/get_git_rev.sh
new file mode 100755
index 00000000..c5ef9457
--- /dev/null
+++ b/script/get_git_rev.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+DIR=$1
+FILE=$2
+
+if [ -d "${DIR}/.git/" ]
+then
+ echo -n "#define GIT_VERSION \"" > ${FILE}.tmp
+ REV=$(git log -1 --pretty=tformat:%h)
+ echo -n "${REV}" >> ${FILE}.tmp
+ echo "\"" >> ${FILE}.tmp
+else
+ echo "#undef GIT_VERSION" > ${FILE}.tmp
+fi
+
+if ! diff ${FILE}.tmp ${FILE} > /dev/null
+then
+ mv ${FILE}.tmp ${FILE}
+else
+ rm ${FILE}.tmp
+fi