Fix a SIGPIPE in the mutation harness's worktree guard (#5434)
Reported by the first caller to use scripts/mutation-equivalence.sh at scale: it killed 5 of 9 mutation runs, presenting as "not a worktree of $REPO" for a path that plainly was one. grep -q exits on the first match, which SIGPIPEs the git worktree list feeding it. Under set -o pipefail the pipeline is then nonzero and the negation takes the failure branch, rejecting a legitimate worktree. It only bites once the listing is large enough that git is still writing when grep exits — this repo has ~370 worktrees and a 53 KB listing — so it reads as intermittent and machine-specific. Captured into a variable instead of piped. Verified both directions: a real worktree is now recognised and falls through to the branch-checked-out guard as intended. The guard this broke was added two commits earlier, in response to a review that found the tool would hard-reset a live checkout. Tightening it introduced a failure mode that made it refuse legitimate ones. Worth recording, because the reflex when a guard misfires is to loosen the guard rather than look for the bug in it — and the caller who hit this worked around the symptom rather than reporting it, which is how a tool acquires a reputation for flakiness.
This commit is contained in:
parent
6b39bcd4ae
commit
869020c221
1 changed files with 8 additions and 1 deletions
|
|
@ -97,7 +97,14 @@ if [ -e "$WT" ]; then
|
|||
echo " cleans that path; running would destroy the checkout it is measuring." >&2
|
||||
exit 2
|
||||
fi
|
||||
if ! git -C "$REPO" worktree list --porcelain | grep -qx "worktree $WT_ABS"; then
|
||||
# Captured into a variable, NOT piped. `grep -q` exits on the first match,
|
||||
# which SIGPIPEs git; with `pipefail` that makes the whole pipeline nonzero and
|
||||
# the negation below then rejects a perfectly good worktree. It only bites once
|
||||
# the list is large enough for git to still be writing — this repo has ~370
|
||||
# worktrees / 53 KB — so it looks intermittent and machine-specific. It killed
|
||||
# 5 of 9 runs for the first caller who hit it.
|
||||
WT_LIST="$(git -C "$REPO" worktree list --porcelain)"
|
||||
if ! grep -qx "worktree $WT_ABS" <<<"$WT_LIST"; then
|
||||
echo "FATAL: $WT exists but is not a worktree of $REPO." >&2
|
||||
echo " This script hard-resets and cleans that path; refusing to touch it." >&2
|
||||
exit 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue