Problem
.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.
Problem
.githooks/validate-k9.shdecides whether a nonconforming K9 file blocks acommit with:
Under
set -o pipefail,grep -qexits as soon as it matches and closes thepipe.
printfthen receives SIGPIPE. On large change lists this produces falsenegatives — 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:
Acceptance
form: a large
$CHANGEDlist where the file is present, asserted to bedetected.
scripts/tests/soscripts/run-shell-test-suite.shpicks it up.
Notes
Deliberately NOT bundled with the 9-archive district move (#1218), which only
added an
is_fixture()case to this script.