Commit 1ff4b54
authored
fix(hooks): guard-git.sh sed patterns work on macOS BSD sed (#1146)
`\s` and the `s///;t;s///` flow-control chain are GNU sed extensions
that BSD sed (macOS default) does not support. When a command like
`cd /path/to/wt && git push` was issued from a different cwd, the
cd-path extraction silently returned an empty string, the hook fell
back to the calling shell's branch, and produced false "Branch does
not match required pattern" denials.
Changes:
- Replace `\s` with `[[:space:]]` in all sed patterns (lines 36, 37, 124).
- Split the `s/quoted/.../p;t;s/unquoted/.../p` chain on the `-C`
extraction into two separate `sed -nE` invocations — BSD sed parses
the chained `s///` after `t` as a label and errors with
"undefined label".
- Update the matching `grep -qE` cd/-C guards to `[[:space:]]` for
consistency.
Verified end-to-end on macOS with all four code paths the hook protects
(cd && push, -C push, -C with quoted path, multi -C, cd + -C precedence).
Closes #11451 parent f2f0571 commit 1ff4b54
1 file changed
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
122 | 127 | | |
123 | | - | |
124 | | - | |
| 128 | + | |
| 129 | + | |
125 | 130 | | |
126 | 131 | | |
127 | 132 | | |
| |||
0 commit comments