You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.githooks/validate-k9.sh decides whether a nonconforming K9 file blocks a
commit with:
if [ -n"$CHANGED" ] &&printf'%s\n'"$CHANGED"| grep -qxF "$file";then
Under set -o pipefail, grep -q exits as soon as it matches and closes the
pipe. printf then receives SIGPIPE. On large change lists this produces false
negatives — a file that WAS touched is reported as untouched, so a change to a
nonconforming file slips through as advisory instead of blocking.
Measured at roughly 12–14% of runs on large change lists.
Fix
Use a here-string so there is no pipe and no SIGPIPE:
if [ -n"$CHANGED" ] && grep -qxF -- "$file"<<<"$CHANGED";then
Acceptance
A regression test that fails on the current form and passes on the fixed
form: a large $CHANGED list where the file is present, asserted to be
detected.
The test lives under scripts/tests/ so scripts/run-shell-test-suite.sh
picks it up.
Fix and test land together.
Notes
Deliberately NOT bundled with the 9-archive district move (#1218), which only
added an is_fixture() case to this script.
Activity