Skip to content

Commit 7bbfd6b

Browse files
committed
Bugfix: Only use git for build info if the repository is actually the right one
Original-Github-Pull: bitcoin#7522 Rebased-From: e98e3dd e98e3dd
1 parent 9dce91a commit 7bbfd6b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

share/genbuild.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ else
1818
exit 1
1919
fi
2020

21+
# 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
22+
git_check_in_repo() {
23+
! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?'
24+
}
25+
2126
GIT_TAG=""
2227
GIT_COMMIT=""
23-
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
28+
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
2429
# clean 'dirty' status of touched files that haven't been modified
2530
git diff >/dev/null 2>/dev/null
2631

0 commit comments

Comments
 (0)