diff --git a/tools/design_amendment_gate.sh b/tools/design_amendment_gate.sh index 82d844ca..de1cfd20 100755 --- a/tools/design_amendment_gate.sh +++ b/tools/design_amendment_gate.sh @@ -33,7 +33,7 @@ is_binding_page() { if [ "$mode" = index ]; then git cat-file -e ":$path" 2>/dev/null || return 1 - git show ":$path" | grep -qE '^Type: (law|spec)$' + git grep --cached -qE '^Type: (law|spec)$' -- "$path" else [ -f "$path" ] && grep -qE '^Type: (law|spec)$' "$path" fi diff --git a/tools/test_design_amendment_gate.sh b/tools/test_design_amendment_gate.sh index 1161bc8b..b5cf2707 100755 --- a/tools/test_design_amendment_gate.sh +++ b/tools/test_design_amendment_gate.sh @@ -57,6 +57,18 @@ Type: knowledge EOF expect_pass "index reads staged binding type" $'crates/game/lib.rs\nwiki/process/law.md' --index +# A large binding page with its Type header near the top must not fail under +# `set -o pipefail` when the matcher exits before a staged blob finishes +# streaming. This reproduces the old `git show | grep -q` SIGPIPE boundary. +{ + printf '# Large spec\nType: spec\n' + for ((i = 0; i < 20000; i++)); do + printf 'binding detail %05d\n' "$i" + done +} > "$tmp/wiki/process/large.md" +git -C "$tmp" add wiki/process/large.md +expect_pass "large staged binding page" $'crates/game/lib.rs\nwiki/process/large.md' --index + # Conversely, a staged deletion is not an amendment merely because an # unstaged file with the same path exists in the worktree. git -C "$tmp" rm --cached -fq wiki/process/law.md