git: Fix panic in git2 due to empty repo paths (#42304)
Fixes ZED-1VR Release Notes: - Fixed sporadic panic in git features
This commit is contained in:
@@ -266,7 +266,7 @@ impl language::File for GitBlob {
|
||||
}
|
||||
|
||||
fn path(&self) -> &Arc<RelPath> {
|
||||
&self.path.0
|
||||
self.path.as_ref()
|
||||
}
|
||||
|
||||
fn full_path(&self, _: &App) -> PathBuf {
|
||||
|
||||
@@ -879,7 +879,7 @@ impl GitPanel {
|
||||
let active_repository = self.active_repository.as_ref()?.downgrade();
|
||||
|
||||
cx.spawn(async move |_, cx| {
|
||||
let file_path_str = repo_path.0.display(PathStyle::Posix);
|
||||
let file_path_str = repo_path.as_ref().display(PathStyle::Posix);
|
||||
|
||||
let repo_root = active_repository.read_with(cx, |repository, _| {
|
||||
repository.snapshot().work_directory_abs_path
|
||||
@@ -1074,7 +1074,7 @@ impl GitPanel {
|
||||
}
|
||||
let mut details = entries
|
||||
.iter()
|
||||
.filter_map(|entry| entry.repo_path.0.file_name())
|
||||
.filter_map(|entry| entry.repo_path.as_ref().file_name())
|
||||
.map(|filename| filename.to_string())
|
||||
.take(5)
|
||||
.join("\n");
|
||||
@@ -1129,7 +1129,7 @@ impl GitPanel {
|
||||
.map(|entry| {
|
||||
entry
|
||||
.repo_path
|
||||
.0
|
||||
.as_ref()
|
||||
.file_name()
|
||||
.map(|f| f.to_string())
|
||||
.unwrap_or_default()
|
||||
@@ -5647,7 +5647,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
entry.status_entry().map(|status| status
|
||||
.repo_path
|
||||
.0
|
||||
.as_ref()
|
||||
.as_std_path()
|
||||
.to_string_lossy()
|
||||
.to_string()),
|
||||
|
||||
@@ -336,7 +336,7 @@ impl ProjectDiff {
|
||||
};
|
||||
let repo = git_repo.read(cx);
|
||||
let sort_prefix = sort_prefix(repo, &entry.repo_path, entry.status, cx);
|
||||
let path_key = PathKey::with_sort_prefix(sort_prefix, entry.repo_path.0);
|
||||
let path_key = PathKey::with_sort_prefix(sort_prefix, entry.repo_path.as_ref().clone());
|
||||
|
||||
self.move_to_path(path_key, window, cx)
|
||||
}
|
||||
@@ -566,7 +566,7 @@ impl ProjectDiff {
|
||||
for entry in buffers_to_load.iter() {
|
||||
let sort_prefix = sort_prefix(&repo, &entry.repo_path, entry.file_status, cx);
|
||||
let path_key =
|
||||
PathKey::with_sort_prefix(sort_prefix, entry.repo_path.0.clone());
|
||||
PathKey::with_sort_prefix(sort_prefix, entry.repo_path.as_ref().clone());
|
||||
previous_paths.remove(&path_key);
|
||||
path_keys.push(path_key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user