Commit 6bf91de9 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'git_branch' into 'master'

Ensure GIT_BRANCH non-empty when not on a branch

If HEAD is detached e.g. during `git bisect`, GIT_BRANCH ends up empty, which causes an error at runtime. This change grabs the description from `git branch`, which is either the branch name or something like `(HEAD detached at <hash>)` on recent versions or `(no branch)` in older versions. Works with BSD and GNU sed, and git >= 1.0.0b (at least) although detached HEAD only introduced in 1.5.0.

See merge request !47
parents 1a8b0e63 a73d8447
...@@ -63,10 +63,10 @@ libswiftsim_mpi_la_SHORTNAME = mpi ...@@ -63,10 +63,10 @@ libswiftsim_mpi_la_SHORTNAME = mpi
version.h: version.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS) version.h: version.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS)
if test "X$(GIT_CMD)" != "X"; then \ if test "X$(GIT_CMD)" != "X"; then \
GIT_REVISION=`$(GIT_CMD) describe --abbrev=8 --always --tags --dirty`; \ GIT_REVISION=`$(GIT_CMD) describe --abbrev=8 --always --tags --dirty`; \
GIT_BRANCH=`$(GIT_CMD) symbolic-ref HEAD| sed 's,.*/,,'`; \ GIT_BRANCH=`$(GIT_CMD) branch | sed -n 's/^\* \(.*\)/\1/p'`; \
sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \ sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
-e "s,@GIT_REVISION\@,$${GIT_REVISION}," \ -e "s,@GIT_REVISION\@,$${GIT_REVISION}," \
-e "s,@GIT_BRANCH\@,$${GIT_BRANCH}," version.h.in > version.h; \ -e "s|@GIT_BRANCH\@|$${GIT_BRANCH}|" version.h.in > version.h; \
else \ else \
if test ! -f version.h; then \ if test ! -f version.h; then \
sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \ sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
......
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