Commit 0d572b3
fix(V3.2-P7): worktree-safe hook prefix — git-common-dir replaces show-toplevel
Hooks failed when Claude Code was opened from a git worktree because
git rev-parse --show-toplevel returns the worktree path, not the main
repo root, causing .memory/hooks/ to be unfindable.
New prefix in generate_hooks_settings():
_r="$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)" \
|| exit 0; _r="${_r%/.git}"; cd "$_r" && ...
- --git-common-dir always resolves to the main repo .git (not the worktree subdir)
- --path-format=absolute gives a consistent absolute path regardless of CWD
- bash suffix removal (no sed, no false match on .github paths)
- Requires git 2.31+ (March 2021)
Bug discovered in QTP worktree session; EFM had the same root cause.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent a8794c6 commit 0d572b3
3 files changed
Lines changed: 40 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
217 | 224 | | |
218 | 225 | | |
219 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
| 432 | + | |
431 | 433 | | |
432 | | - | |
| 434 | + | |
433 | 435 | | |
434 | | - | |
| 436 | + | |
435 | 437 | | |
436 | 438 | | |
437 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
7 | 35 | | |
8 | 36 | | |
9 | 37 | | |
| |||
0 commit comments