Repository navigation
fix(switch): resolve symlinked paths to existing worktrees - #2466
Merged
Merged
Conversation
worktrunk-bot
commented
Apr 29, 2026
worktrunk-bot
left a comment
Collaborator
Author
There was a problem hiding this comment.
One small visibility nit inline. The fix itself is right — canonicalizing both sides via canonicalize_with_parents resolves the symlink-blindness in worktree_at_path, and the worktree_at_path_resolves_symlinked_path unit test directly reproduces the bug from #2460.
Owner
|
@worktrunk-bot fix conflicts |
`worktree_at_path` compared paths via lexical normalization, so a symlink whose target was a worktree did not match — causing `wt switch /tmp/link-to-worktree` to fail with `No branch named ...`. Move `paths_match` / `canonicalize_with_parents` from `commands/worktree/resolve.rs` into `worktrunk::path` and switch `worktree_at_path` to the symlink-aware comparison. Closes #2460 Co-Authored-By: Claude <noreply@anthropic.com>
It's only used by paths_match (same module) and tests via super::, matching the original visibility before the move from resolve.rs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collapse the two early returns into a single tuple-matched fallback and add a test that exercises the degenerate path. Codecov flagged both branches as uncovered; consolidating them lets the empty-path test reach the only fallback. Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
force-pushed
the
fix/issue-2460
branch
from
April 29, 2026 19:11
13d28fe to
90f34d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
wt switch /path/to/symlinkfailed withNo branch named ...when the target was a symlink resolving to an existing worktree, whilewt switch /path/to/real-worktreesucceeded.The path-based fallback for existing worktrees (
Repository::worktree_at_path) compared paths via lexical normalization (normalize_path::NormalizePath::normalize) only — symlink-equivalent spellings never matched.Solution
Move
paths_match/canonicalize_with_parentsfromsrc/commands/worktree/resolve.rstoworktrunk::pathso they're reachable from the library crate, and switchworktree_at_pathto use the symlink-aware comparison. The original location used the helper to detect path-mismatch warnings; the same logic now powers worktree identity.Testing
worktree_at_path_resolves_symlinked_pathinsrc/git/repository/tests.rsreproduces the bug — fails onmain, passes after the fix.test_switch_worktree_by_symlinked_pathintests/integration_tests/switch.rscovers the end-to-endwt switch <symlink>path.Closes #2460 — automated triage