Skip to content

[dh] fix: resolve -w flag by directory name, not just branch name#116

Merged
jamiesunderland merged 2 commits intomainfrom
fix/worktree-resolve-by-dirname
Mar 22, 2026
Merged

[dh] fix: resolve -w flag by directory name, not just branch name#116
jamiesunderland merged 2 commits intomainfrom
fix/worktree-resolve-by-dirname

Conversation

@dahyman91
Copy link
Contributor

coast assign -w foo now finds .claude/worktrees/foo even when its branch is worktree-foo. The worktree resolution order is:

  1. Directory name match in local worktree dirs
  2. Directory name then branch name match in external dirs
  3. Branch name match in local dirs (new)
  4. Auto-detected git worktree dir (for new worktree creation)
  5. Default fallback

Previously try_git_detected ran first and short-circuited the directory-name lookup, causing Coast to create a duplicate worktree instead of mounting the existing one.

Also splits match_porcelain_to_external into two passes (directory first, branch second) so directory matches are always preferred.

coast assign -w foo now finds .claude/worktrees/foo even when its
branch is worktree-foo. The worktree resolution order is:

1. Directory name match in local worktree dirs
2. Directory name then branch name match in external dirs
3. Branch name match in local dirs (new)
4. Auto-detected git worktree dir (for new worktree creation)
5. Default fallback

Previously try_git_detected ran first and short-circuited the
directory-name lookup, causing Coast to create a duplicate worktree
instead of mounting the existing one.

Also splits match_porcelain_to_external into two passes (directory
first, branch second) so directory matches are always preferred.
@dahyman91 dahyman91 marked this pull request as draft March 22, 2026 19:45
Copy link
Contributor

@jamiesunderland jamiesunderland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested on my end, works now

@jamiesunderland jamiesunderland marked this pull request as ready for review March 22, 2026 21:03
@jamiesunderland jamiesunderland merged commit f9c96e7 into main Mar 22, 2026
2 checks passed
@jamiesunderland jamiesunderland deleted the fix/worktree-resolve-by-dirname branch March 22, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants