Skip to content

Conversation

@abhi-kr-2100
Copy link

Motivation:

  • Users frequently abbreviate branch names when switching to existing worktrees (e.g., 'wt switch feat' for 'feature/long-branch-name')
  • Current strict matching requires exact branch names, reducing usability
  • Need to balance convenience with safety for operations like branch creation

Changes:

  • Add WorktreeResolutionMode enum to control fuzzy vs strict matching behavior
  • Implement Smith-Waterman fuzzy matching using nucleo-matcher library
  • Update Repository::resolve_worktree_name() and resolve_target_branch() to accept resolution mode parameter
  • Use fuzzy mode only for 'wt switch' without --create flag
  • Use strict mode for:
    • 'wt switch -c' (branch creation should require exact names)
    • All merge/rebase/push operations (must target exact branches)
    • Explicit --base arguments (always require exact matches)
  • Add comprehensive unit tests for fuzzy matching behavior
  • Add implementation notes documenting the design and behavior

Benefits:

  • Improved UX for switching to existing worktrees with abbreviated names
  • Prevents accidental branch creation with misspelled names
  • Consistent strict matching for merge/rebase targets
  • Backward compatible - exact matches still work as before

@abhi-kr-2100 abhi-kr-2100 force-pushed the abhi-kr-2100-fuzzy-match-branches branch from f34908b to 447044f Compare January 8, 2026 15:30
@abhi-kr-2100 abhi-kr-2100 reopened this Jan 8, 2026
Motivation:
- Users frequently abbreviate branch names when switching to existing worktrees (e.g., 'wt switch feat' for 'feature/long-branch-name')
- Current strict matching requires exact branch names, reducing usability
- Need to balance convenience with safety for operations like branch creation

Changes:
- Add WorktreeResolutionMode enum to control fuzzy vs strict matching behavior
- Implement Smith-Waterman fuzzy matching using nucleo-matcher library
- Update Repository::resolve_worktree_name() and resolve_target_branch() to accept resolution mode parameter
- Use fuzzy mode only for 'wt switch' without --create flag
- Use strict mode for:
  - 'wt switch -c' (branch creation should require exact names)
  - All merge/rebase/push operations (must target exact branches)
  - Explicit --base arguments (always require exact matches)
- Add comprehensive unit tests for fuzzy matching behavior
- Add implementation notes documenting the design and behavior

Benefits:
- Improved UX for switching to existing worktrees with abbreviated names
- Prevents accidental branch creation with misspelled names
- Consistent strict matching for merge/rebase targets
- Backward compatible - exact matches still work as before

Signed-off-by: Abhishek Kumar <[email protected]>
@abhi-kr-2100 abhi-kr-2100 force-pushed the abhi-kr-2100-fuzzy-match-branches branch from 447044f to b6edc10 Compare January 8, 2026 15:51
@max-sixty
Copy link
Owner

we definitely can't have wt switch release-0.9.0 switching to release-0.8.0...

could try it on auto-completion targets potentially?

@abhi-kr-2100
Copy link
Author

we definitely can't have wt switch release-0.9.0 switching to release-0.8.0...

could try it on auto-completion targets potentially?

@max-sixty If there's a branch called release-0.8.0 but no branch called release-0.9.0, wt switch release-0.9.0 will not switch to release-0.8.0.

Did I understand your concern correctly?

By auto-completion targets, do you mean auto-completing branch names?

@max-sixty
Copy link
Owner

@max-sixty If there's a branch called release-0.8.0 but no branch called release-0.9.0, wt switch release-0.9.0 will not switch to release-0.8.0.

Did I understand your concern correctly?

yes — it's important branch names match exactly

By auto-completion targets, do you mean auto-completing branch names?

yes, on hitting tab, maybe there's more flexibliity there

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