Skip to content

Fix remote worktree path separators - #55486

Merged
maxbrunsfeld merged 3 commits into
zed-industries:mainfrom
hayatosc:fix/wsl-worktree
May 6, 2026
Merged

Fix remote worktree path separators#55486
maxbrunsfeld merged 3 commits into
zed-industries:mainfrom
hayatosc:fix/wsl-worktree

Conversation

@hayatosc

@hayatosc hayatosc commented May 2, 2026

Copy link
Copy Markdown
Contributor

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #54641

Release Notes:

  • Fixed creating git worktrees in WSL remote projects from Windows.

Summary

  • Preserve the repository PathStyle when constructing git worktree paths.
  • Avoid using local OS path separators when creating worktrees for remote Posix projects such as WSL.
  • Keep worktree archive path checks aligned with the same path-style-aware worktree directory calculation.

Root Cause

Remote repository paths are stored as PathBufs, but PathBuf::join and related path operations use the client OS separator. On Windows clients connected to WSL, this could turn a remote Linux path into a mixed path like /home/<user>/\home\<user>\dev\worktrees\..., causing worktree creation and opening to fail.

Validation

  • cargo fmt --all --check
  • git diff --check
  • cargo test -p project test_new_worktree_path_uses_posix_style_for_remote_paths
  • cargo test -p project test_worktree_directory_uses_remote_path_style
  • cargo test -p project test_join_path_for_style_uses_remote_separator

@cla-bot

cla-bot Bot commented May 2, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @hayatosc on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label May 2, 2026
@hayatosc

hayatosc commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot

cla-bot Bot commented May 2, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @hayatosc on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot

cla-bot Bot commented May 2, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@hayatosc

hayatosc commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 2, 2026
@cla-bot

cla-bot Bot commented May 2, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@hayatosc
hayatosc marked this pull request as ready for review May 2, 2026 12:24
@ChristopherBiscardi ChristopherBiscardi added platform:windows/wsl Platform-specific feedback for WSL platform:remote Remote development, SSH and zed-remote-server labels May 5, 2026
@maxbrunsfeld
maxbrunsfeld enabled auto-merge May 5, 2026 23:49
@maxbrunsfeld

Copy link
Copy Markdown
Collaborator

Thank you @hayatosc - I made a small tweak to move the path-joining method to the PathStyle impl.

@maxbrunsfeld
maxbrunsfeld added this pull request to the merge queue May 6, 2026
Merged via the queue into zed-industries:main with commit 7b2acab May 6, 2026
31 checks passed
@hayatosc
hayatosc deleted the fix/wsl-worktree branch May 6, 2026 08:31
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#54641

Release Notes:

- Fixed creating git worktrees in WSL remote projects from Windows.

## Summary

- Preserve the repository `PathStyle` when constructing git worktree
paths.
- Avoid using local OS path separators when creating worktrees for
remote Posix projects such as WSL.
- Keep worktree archive path checks aligned with the same
path-style-aware worktree directory calculation.

## Root Cause

Remote repository paths are stored as `PathBuf`s, but `PathBuf::join`
and related path operations use the client OS separator. On Windows
clients connected to WSL, this could turn a remote Linux path into a
mixed path like `/home/<user>/\home\<user>\dev\worktrees\...`, causing
worktree creation and opening to fail.

## Validation

- `cargo fmt --all --check`
- `git diff --check`
- `cargo test -p project
test_new_worktree_path_uses_posix_style_for_remote_paths`
- `cargo test -p project test_worktree_directory_uses_remote_path_style`
- `cargo test -p project test_join_path_for_style_uses_remote_separator`

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
@kylekz kylekz mentioned this pull request May 8, 2026
3 tasks
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#54641

Release Notes:

- Fixed creating git worktrees in WSL remote projects from Windows.

## Summary

- Preserve the repository `PathStyle` when constructing git worktree
paths.
- Avoid using local OS path separators when creating worktrees for
remote Posix projects such as WSL.
- Keep worktree archive path checks aligned with the same
path-style-aware worktree directory calculation.

## Root Cause

Remote repository paths are stored as `PathBuf`s, but `PathBuf::join`
and related path operations use the client OS separator. On Windows
clients connected to WSL, this could turn a remote Linux path into a
mixed path like `/home/<user>/\home\<user>\dev\worktrees\...`, causing
worktree creation and opening to fail.

## Validation

- `cargo fmt --all --check`
- `git diff --check`
- `cargo test -p project
test_new_worktree_path_uses_posix_style_for_remote_paths`
- `cargo test -p project test_worktree_directory_uses_remote_path_style`
- `cargo test -p project test_join_path_for_style_uses_remote_separator`

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#54641

Release Notes:

- Fixed creating git worktrees in WSL remote projects from Windows.

## Summary

- Preserve the repository `PathStyle` when constructing git worktree
paths.
- Avoid using local OS path separators when creating worktrees for
remote Posix projects such as WSL.
- Keep worktree archive path checks aligned with the same
path-style-aware worktree directory calculation.

## Root Cause

Remote repository paths are stored as `PathBuf`s, but `PathBuf::join`
and related path operations use the client OS separator. On Windows
clients connected to WSL, this could turn a remote Linux path into a
mixed path like `/home/<user>/\home\<user>\dev\worktrees\...`, causing
worktree creation and opening to fail.

## Validation

- `cargo fmt --all --check`
- `git diff --check`
- `cargo test -p project
test_new_worktree_path_uses_posix_style_for_remote_paths`
- `cargo test -p project test_worktree_directory_uses_remote_path_style`
- `cargo test -p project test_join_path_for_style_uses_remote_separator`

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions platform:remote Remote development, SSH and zed-remote-server platform:windows/wsl Platform-specific feedback for WSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree creation in remote (WSL2) project uses backslashes and fails to open

3 participants