Skip to content

fix: resolve worktree paths with slashes in remove/destroy#12

Merged
ahmedelgabri merged 2 commits intomainfrom
fix/remove-nested-worktree
Feb 17, 2026
Merged

fix: resolve worktree paths with slashes in remove/destroy#12
ahmedelgabri merged 2 commits intomainfrom
fix/remove-nested-worktree

Conversation

@ahmedelgabri
Copy link
Owner

@ahmedelgabri ahmedelgabri commented Feb 17, 2026

Fixes #11

  • git wt remove and git wt destroy failed to find worktrees created at slash-containing paths (e.g., feature/my-thing) when running from a different worktree
  • Added a relative-to-bare-root matching strategy in resolve_worktree_path() that joins the bare root with user input to match against cached paths
  • Fixed validate_worktree() error message to show paths relative to the bare root instead of just basenames (so feature/nested shows instead of nested)

Set TERM=dumb for treefmt to prevent termenv color detection
queries from leaking into hook output.
When worktrees are created with slash-containing paths (e.g.,
feature/my-thing), `git wt remove` and `git wt destroy` failed to
find them because resolve_worktree_path() only matched by basename
(last path component). Running from a different worktree made
realpath resolution fail too.

Add a relative-to-bare-root matching strategy that joins the bare
root with the user input and checks against cached paths. Also fix
validate_worktree to show paths relative to the bare root instead
of just basenames, so nested worktrees are identifiable in error
messages.

Closes #11
@ahmedelgabri ahmedelgabri marked this pull request as ready for review February 17, 2026 17:00
@ahmedelgabri ahmedelgabri merged commit f5464fd into main Feb 17, 2026
7 checks passed
@ahmedelgabri ahmedelgabri deleted the fix/remove-nested-worktree branch February 17, 2026 17:00
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.

git wt add defaults to slash-containing worktree paths, creating nested directories and breaking git wt remove

1 participant