Cloudy & Associates

Commit 40abf3fa authored by Chatzikos, Marios's avatar Chatzikos, Marios
Browse files

Fix bug with revision string sans git repo

The previous implementation assumed a .git repository be present.  This
is obviously not true for release tarballs.  In that case, gitversion.sh
emits git's fatal warnings that a repository was not found, the revision
is set to the empty string, and the smoke test crashes in version.cpp.

Add a test in gitversion.sh to gracefully handle check for a git
repository being present, and modify version.cpp to handle empty
revision strings.

Reported-by: Peter van Hoof
parent 9d622692
......@@ -13,7 +13,15 @@
# Author: M. Chatzikos
# Comment: Added support for git tags.
#
# Updated: Oct 18, 2022
# Author: M. Chatzikos
# Comment: Added support for compilation sans git (e.g., release tarballs).
#
is_repo=`git rev-parse --is-inside-work-tree 2>&1 | grep true`
if [[ $is_repo != 'true' ]]; then
echo
exit 1
fi
branch=`git branch | grep '^\*' | awk '{ print $2 }'`
tag=`git describe --tags --abbrev=0 2> /dev/null`
if [ -z "$tag" ]; then
......
......@@ -27,7 +27,7 @@ t_version::t_version()
// followed by a tag, or by a git SHA1 commit string, and a modification
// identifier
if( strcmp( revision, "rev_not_set" ) != 0 )
if( strcmp( revision, "" ) != 0 && strcmp( revision, "rev_not_set" ) != 0 )
{
vector<string> Part;
string rev = revision;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment