Fix git features not working when a Windows host collaborates with a unix guest (#43515)

We were using `std::path::Path::strip_prefix` to determine which
repository an absolute path belongs to, which doesn't work when the
paths are Windows-style but the code is running on unix. Replace it with
a platform-agnostic implementation of `strip_prefix`.

Release Notes:

- Fixed git features not working when a Windows host collaborates with a
unix guest
This commit is contained in:
Cole Miller
2025-11-26 16:56:34 +00:00
committed by GitHub
parent 57e1bb8106
commit 757c043171
15 changed files with 159 additions and 30 deletions
+2 -4
View File
@@ -3222,10 +3222,8 @@ impl RepositorySnapshot {
abs_path: &Path,
path_style: PathStyle,
) -> Option<RepoPath> {
abs_path
.strip_prefix(&work_directory_abs_path)
.ok()
.and_then(|path| RepoPath::from_std_path(path, path_style).ok())
let rel_path = path_style.strip_prefix(abs_path, work_directory_abs_path)?;
Some(RepoPath::from_rel_path(&rel_path))
}
pub fn had_conflict_on_last_merge_head_change(&self, repo_path: &RepoPath) -> bool {
+1 -1
View File
@@ -927,7 +927,7 @@ impl DirectoryLister {
.map(|worktree| worktree.read(cx).abs_path().to_string_lossy().into_owned())
.or_else(|| std::env::home_dir().map(|dir| dir.to_string_lossy().into_owned()))
.map(|mut s| {
s.push_str(path_style.separator());
s.push_str(path_style.primary_separator());
s
})
.unwrap_or_else(|| {