zed/crates/util
hayatosc 7b2acab040
Fix remote worktree path separators (#55486)
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 #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>
2026-05-06 00:06:51 +00:00
..
src Fix remote worktree path separators (#55486) 2026-05-06 00:06:51 +00:00
Cargo.toml Remove std::fs::read_link in fs (#50974) 2026-03-14 20:02:34 -04:00
LICENSE-APACHE