Bugfix: Only use git for build info if the repository is actually the right one

Original-Github-Pull: #7522
Rebased-From: e98e3dde6a e98e3dde6a
This commit is contained in:
Luke Dashjr 2016-02-12 05:36:55 +00:00
parent 9dce91a2d9
commit 7bbfd6bc60

View File

@ -18,9 +18,14 @@ else
exit 1
fi
# This checks that we are actually part of the intended git repository, and not just getting info about some unrelated git repository that the code happens to be in a directory under
git_check_in_repo() {
! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?'
}
GIT_TAG=""
GIT_COMMIT=""
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then
# clean 'dirty' status of touched files that haven't been modified
git diff >/dev/null 2>/dev/null