diff --git a/packages/mosaic/framework/tools/git/test-detect-platform-outside-repo.sh b/packages/mosaic/framework/tools/git/test-detect-platform-outside-repo.sh index fa7978c3..13955f0e 100755 --- a/packages/mosaic/framework/tools/git/test-detect-platform-outside-repo.sh +++ b/packages/mosaic/framework/tools/git/test-detect-platform-outside-repo.sh @@ -27,8 +27,21 @@ run_outside() { # $1=function name -> "rc:sawmessage" } check() { if [ "$2" = "$3" ]; then echo " PASS $1 ($2)"; else echo " FAIL $1: got $2, want $3"; fail=1; fi; } -# $TMP is deliberately not a git repo, and must not be inside one. -( cd "$TMP" && git rev-parse --git-dir >/dev/null 2>&1 ) && { echo " SKIP scratch dir is inside a repo"; exit 0; } +# $TMP must not be inside a git repo. Do not SKIP on failure: be-coder-07 showed the +# original SKIP exited 0, so pointing TMPDIR beneath a git worktree made this test PASS +# against unchanged main. A skip that exits 0 is indistinguishable from a pass. +# GIT_CEILING_DIRECTORIES stops git walking above $TMP, making the condition hold +# regardless of where TMPDIR lives, rather than merely detecting when it does not. +# GIT_CEILING_DIRECTORIES is matched against the PHYSICAL path -- a symlinked TMPDIR +# (/tmp is commonly one) makes the logical path never match, and the ceiling silently +# does nothing. Resolve it before exporting. +TMP="$(cd "$TMP" && pwd -P)" +export GIT_CEILING_DIRECTORIES="$TMP" +if ( cd "$TMP" && git rev-parse --git-dir >/dev/null 2>&1 ); then + echo " FAIL scratch dir is inside a git repo even with GIT_CEILING_DIRECTORIES set;" + echo " the outside-a-repo precondition cannot be established -- refusing to report a result" + exit 1 +fi echo "== outside a git repo: rc=1 AND the diagnostic is emitted ==" check "detect_platform" "$(run_outside detect_platform)" "1:yes"