fix(git): find .beads from nested worktrees (GH#509)

When worktrees are nested under the main repo (e.g.,
/project/.worktrees/feature/), bd now correctly finds .beads/ in the
parent repo.

The fix simplifies GetMainRepoRoot() to use `git rev-parse --git-common-dir`
which always returns the main repo's .git directory, regardless of whether
we're in a regular repo, a worktree, or a nested worktree.

- Simplified GetMainRepoRoot() implementation
- Added tests for nested worktree scenarios
- Updated CHANGELOG.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-14 17:20:46 -08:00
parent 0e70c813c7
commit 69d14e21d8
3 changed files with 226 additions and 40 deletions

View File

@@ -30,6 +30,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Worktree lifecycle management with sparse checkout for sync branches
- Automatic detection and user-friendly warnings for worktree conflicts
### Fixed
- **`bd` now finds `.beads` from nested worktrees** (GH#509)
- When worktrees are nested under the main repo (e.g., `/project/.worktrees/feature/`),
`bd` now correctly finds `.beads/` in the parent repo
- Uses `git rev-parse --git-common-dir` to reliably locate the main repository root
- Works from any subdirectory within the nested worktree
## [0.29.0] - 2025-12-03
### Added