You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(worktree): use flat .WT. sibling pattern for worktree path generation
WHY: The previous nested pattern `../{repo}-worktrees/{branch}` created an
intermediate container directory between the parent and each worktree. This
breaks when the repository is a git submodule, because the extra nesting level
changes relative paths that git uses internally to link worktrees back to
their parent repository.
WHAT: Replaced the two-level worktree path pattern with a flat sibling
convention using `.WT.` as an infix separator:
- Before: `../hug-scm-worktrees/feature-auth/` (nested in container)
- After: `../hug-scm.WT.feature-auth/` (flat sibling)
Key design decision: The `.WT.` uppercase-dot-delimited infix was chosen over
`-wt-` because it provides stronger visual identification when scanning
directory listings. The dots act as a clear structural delimiter between the
repo name and the branch name, while the uppercase stands out against the
lowercase hyphen-cased names on both sides. Dots are safe here because the
branch sanitization (which converts dots to hyphens) applies only to the
branch portion, not the structural separator.
HOW: Single behavioral change in `generate_worktree_path()` in hug-git-worktree:
- Path pattern: `../{repo}.WT.{branch}` (flat, no container directory)
- Removed `mkdir -p` for intermediate directory (parent `..` always exists)
- Added writability check on parent with `/tmp` fallback
- `generate_unique_worktree_path()` inherits the new pattern automatically
IMPACT: Worktree creation now works correctly inside git submodules without
path resolution issues. No migration needed — git tracks worktrees by absolute
path internally, so existing worktrees created with the old pattern continue
working. The test helper `create_test_worktree()` was also aligned to use
the same `.WT.` pattern, ensuring production and test code share the same
path convention. All 1572 BATS + 439 Python tests pass.
🤖 Generated with [Qoder][https://qoder.com]
0 commit comments