Skip to content

Commit 3c862aa

Browse files
authored
Merge branch 'main' into fix/1136-cargo-rustup-init-shim
2 parents 919af21 + 1ff4b54 commit 3c862aa

2 files changed

Lines changed: 89 additions & 84 deletions

File tree

.claude/hooks/guard-git.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ fi
3333
# the opening `"` of a quoted path (which would leave a trailing `path"` in
3434
# NCOMMAND). The pattern re-anchors on `git`, so multi-`-C` chains (e.g.
3535
# `git -C /a -C /b push`) need a second pass to collapse the residual `-C`.
36-
NCOMMAND=$(echo "$COMMAND" | sed -E 's/(^|\s|&&\s*)git[[:space:]]+-C[[:space:]]+"[^"]+"/\1git/g; s/(^|\s|&&\s*)git[[:space:]]+-C[[:space:]]+[^"[:space:]][^[:space:]]*/\1git/g')
37-
NCOMMAND=$(echo "$NCOMMAND" | sed -E 's/(^|\s|&&\s*)git[[:space:]]+-C[[:space:]]+"[^"]+"/\1git/g; s/(^|\s|&&\s*)git[[:space:]]+-C[[:space:]]+[^"[:space:]][^[:space:]]*/\1git/g')
36+
NCOMMAND=$(echo "$COMMAND" | sed -E 's/(^|[[:space:]]|&&[[:space:]]*)git[[:space:]]+-C[[:space:]]+"[^"]+"/\1git/g; s/(^|[[:space:]]|&&[[:space:]]*)git[[:space:]]+-C[[:space:]]+[^"[:space:]][^[:space:]]*/\1git/g')
37+
NCOMMAND=$(echo "$NCOMMAND" | sed -E 's/(^|[[:space:]]|&&[[:space:]]*)git[[:space:]]+-C[[:space:]]+"[^"]+"/\1git/g; s/(^|[[:space:]]|&&[[:space:]]*)git[[:space:]]+-C[[:space:]]+[^"[:space:]][^[:space:]]*/\1git/g')
3838

3939
deny() {
4040
local reason="$1"
@@ -117,11 +117,16 @@ detect_work_dir() {
117117
# `git -C` is the explicit git-level override and wins over any ambient cd prefix,
118118
# so check it first (e.g. `cd /tmp && git -C /worktree push` targets /worktree).
119119
# Greedy `.*-C` anchors on the LAST `-C` in the chosen segment.
120-
if echo "$search_str" | grep -qE 'git\s+([^&|;]*\s)?-C\s+'; then
121-
work_dir=$(echo "$search_str" | sed -nE 's/.*-C[[:space:]]+"([^"]+)".*/\1/p;t;s/.*-C[[:space:]]+([^[:space:]]+).*/\1/p')
120+
# Two separate sed invocations (quoted path first, then unquoted fallback) instead
121+
# of a single `;t;s` chain — BSD sed parses chained s/// after `t` as a label.
122+
if echo "$search_str" | grep -qE 'git[[:space:]]+([^&|;]*[[:space:]])?-C[[:space:]]+'; then
123+
work_dir=$(echo "$search_str" | sed -nE 's/.*-C[[:space:]]+"([^"]+)".*/\1/p')
124+
if [ -z "$work_dir" ]; then
125+
work_dir=$(echo "$search_str" | sed -nE 's/.*-C[[:space:]]+([^[:space:]]+).*/\1/p')
126+
fi
122127
fi
123-
if [ -z "$work_dir" ] && echo "$COMMAND" | grep -qE '^\s*cd\s+'; then
124-
work_dir=$(echo "$COMMAND" | sed -nE 's/^\s*cd\s+"?([^"&]+)"?\s*&&.*/\1/p')
128+
if [ -z "$work_dir" ] && echo "$COMMAND" | grep -qE '^[[:space:]]*cd[[:space:]]+'; then
129+
work_dir=$(echo "$COMMAND" | sed -nE 's/^[[:space:]]*cd[[:space:]]+"?([^"&]+)"?[[:space:]]*&&.*/\1/p')
125130
fi
126131
# Trim trailing whitespace
127132
work_dir="${work_dir%"${work_dir##*[![:space:]]}"}"

package-lock.json

Lines changed: 78 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)