Skip to content

fix(plugin): preserve branch slashes in worktree path to match CLI#47

Merged
guodong-sq merged 1 commit intomainfrom
fix/plugin-branch-path-parity
Mar 22, 2026
Merged

fix(plugin): preserve branch slashes in worktree path to match CLI#47
guodong-sq merged 1 commit intomainfrom
fix/plugin-branch-path-parity

Conversation

@guodong-sq
Copy link
Collaborator

Summary

The plugin's GitBranchHelper.worktreePathForBranch replaced / with - in branch names, creating flat directory names (e.g., test-foo). The CLI uses the branch name verbatim as a path, creating nested directories (e.g., test/foo). This caused worktrees created by CLI and plugin for the same branch to land at different locations.

Fix: remove the replace("/", "-") call. Path.resolve("test/foo") naturally creates the nested path, matching CLI behavior. Path traversal is still blocked by sanitizeBranchName rejecting ...

Test plan

  • Plugin tests pass: cd wt-jetbrains-plugin && ./gradlew test
  • Branch feature/foo → worktree at worktreesBase/feature/foo (not feature-foo)
  • Branch simple → worktree at worktreesBase/simple (unchanged)
  • sanitizeBranchName still rejects ..

🤖 Generated with Claude Code

The plugin's GitBranchHelper.worktreePathForBranch replaced '/' with '-'
in branch names, creating flat directory names (e.g., test-foo). The CLI
uses the branch name verbatim, creating nested directories (e.g.,
test/foo). This caused worktrees created by CLI and plugin for the same
branch to land at different paths.

Match the CLI behavior: use the branch name directly as a path, letting
'/' create subdirectories. Path traversal is still blocked by
sanitizeBranchName rejecting '..' in branch names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@guodong-sq guodong-sq merged commit e59f4d0 into main Mar 22, 2026
6 checks passed
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.

1 participant