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:
@@ -999,7 +999,7 @@ impl Worktree {
|
||||
};
|
||||
|
||||
if worktree_relative_path.components().next().is_some() {
|
||||
full_path_string.push_str(self.path_style.separator());
|
||||
full_path_string.push_str(self.path_style.primary_separator());
|
||||
full_path_string.push_str(&worktree_relative_path.display(self.path_style));
|
||||
}
|
||||
|
||||
@@ -2108,8 +2108,8 @@ impl Snapshot {
|
||||
if path.file_name().is_some() {
|
||||
let mut abs_path = self.abs_path.to_string();
|
||||
for component in path.components() {
|
||||
if !abs_path.ends_with(self.path_style.separator()) {
|
||||
abs_path.push_str(self.path_style.separator());
|
||||
if !abs_path.ends_with(self.path_style.primary_separator()) {
|
||||
abs_path.push_str(self.path_style.primary_separator());
|
||||
}
|
||||
abs_path.push_str(component);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user