meson-vcs-tag: add work-around for git bug

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-12-19 13:25:07 +01:00
parent 681bd2c524
commit e4d5753bd0
2 changed files with 6 additions and 3 deletions

View file

@ -584,7 +584,7 @@ endif
#####################################################################
vcs_tagger = [meson.source_root() + '/tools/meson-vcs-tag.sh',
'@0@/.git'.format(meson.source_root()),
meson.source_root(),
meson.project_version()]
sed = find_program('sed')

View file

@ -3,7 +3,10 @@
set -eu
set -o pipefail
gitdir="$1"
dir="$1"
fallback="$2"
git --git-dir="$gitdir" describe --abbrev=7 --dirty=+ 2>/dev/null | sed 's/^v//' || echo "$fallback"
# Apparently git describe has a bug where it always considers the work-tree
# dirty when invoked with --git-dir (even though 'git status' is happy). Work
# around this issue by cd-ing to the source directory.
cd "$dir" && git describe --abbrev=7 --dirty=+ 2>/dev/null | sed 's/^v//' || echo "$fallback"