fix(hooks): guard-git.sh uses [[:space:]] in sed for BSD compatibility#1153
fix(hooks): guard-git.sh uses [[:space:]] in sed for BSD compatibility#1153carlos-alm wants to merge 1 commit into
Conversation
BSD sed (default on macOS) does not interpret \s as whitespace, so the cd-prefix and git -C normalization regexes silently produced no output. detect_work_dir then fell back to the shell cwd's branch, blocking valid pushes from worktrees with non-conformant cwd names. Closes #1132
Greptile SummaryThis PR fixes a macOS/BSD compatibility bug in
Confidence Score: 4/5Safe to merge — the change is a targeted, correctly scoped portability fix with no behavioral change on GNU/Linux and a verified fix on macOS. The three sed fixes are complete and correct for the reported issue. The only follow-up consideration is that roughly a dozen grep -qE patterns still use \s, which works on BSD grep in practice but is a minor consistency gap worth addressing in a follow-up. .claude/hooks/guard-git.sh — straightforward change; the grep patterns left untouched are worth a follow-up pass for uniformity. Important Files Changed
|
|
Thanks for the review @greptileai. This PR is being closed as superseded — PR #1146 (already merged on The remaining |
|
Closing as superseded by #1146 (already merged on main). PR #1146 fixed both BSD-sed root causes in
The diff in this PR would partially revert #1146 (it restores Follow-up filed as #1157 for the remaining |
Summary
\sas whitespace, so thecd <path> && git ...extractor and thegit -Cnormalization regexes in.claude/hooks/guard-git.shsilently produced no output.detect_work_dirthen fell back to the shell cwd's branch, blocking valid pushes from worktrees whose cwd had a non-conformant branch name (e.g.worktree-agent-<hash>).\ssites in sed regexes with[[:space:]], which is portable across BSD and GNU sed.Test plan
{"command":"cd /tmp/fake-wt && git push origin HEAD:fix/some-fix"}while cwd is on a non-conformant branch — hook now exits 0 (previously denied).\sas literalsand[[:space:]]as expected.Closes #1132