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:
@@ -227,7 +227,7 @@ impl sum_tree::Item for StatusEntry {
|
||||
|
||||
fn summary(&self, _: <Self::Summary as sum_tree::Summary>::Context<'_>) -> Self::Summary {
|
||||
PathSummary {
|
||||
max_path: self.repo_path.0.clone(),
|
||||
max_path: self.repo_path.as_ref().clone(),
|
||||
item_summary: self.status.summary(),
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ impl sum_tree::KeyedItem for StatusEntry {
|
||||
type Key = PathKey;
|
||||
|
||||
fn key(&self) -> Self::Key {
|
||||
PathKey(self.repo_path.0.clone())
|
||||
PathKey(self.repo_path.as_ref().clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -990,7 +990,7 @@ impl GitStore {
|
||||
RepositoryState::Local { backend, .. } => backend
|
||||
.blame(repo_path.clone(), content)
|
||||
.await
|
||||
.with_context(|| format!("Failed to blame {:?}", repo_path.0))
|
||||
.with_context(|| format!("Failed to blame {:?}", repo_path.as_ref()))
|
||||
.map(Some),
|
||||
RepositoryState::Remote { project_id, client } => {
|
||||
let response = client
|
||||
@@ -2376,7 +2376,7 @@ impl GitStore {
|
||||
.entries
|
||||
.into_iter()
|
||||
.map(|(path, status)| proto::TreeDiffStatus {
|
||||
path: path.0.to_proto(),
|
||||
path: path.as_ref().to_proto(),
|
||||
status: match status {
|
||||
TreeDiffStatus::Added {} => proto::tree_diff_status::Status::Added.into(),
|
||||
TreeDiffStatus::Modified { .. } => {
|
||||
@@ -3152,13 +3152,13 @@ impl RepositorySnapshot {
|
||||
|
||||
pub fn status_for_path(&self, path: &RepoPath) -> Option<StatusEntry> {
|
||||
self.statuses_by_path
|
||||
.get(&PathKey(path.0.clone()), ())
|
||||
.get(&PathKey(path.as_ref().clone()), ())
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn pending_ops_for_path(&self, path: &RepoPath) -> Option<PendingOps> {
|
||||
self.pending_ops_by_path
|
||||
.get(&PathKey(path.0.clone()), ())
|
||||
.get(&PathKey(path.as_ref().clone()), ())
|
||||
.cloned()
|
||||
}
|
||||
|
||||
@@ -4727,7 +4727,9 @@ impl Repository {
|
||||
}
|
||||
};
|
||||
Some((
|
||||
RepoPath(RelPath::from_proto(&entry.path).log_err()?),
|
||||
RepoPath::from_rel_path(
|
||||
&RelPath::from_proto(&entry.path).log_err()?,
|
||||
),
|
||||
status,
|
||||
))
|
||||
})
|
||||
@@ -5289,7 +5291,8 @@ impl Repository {
|
||||
let mut cursor = prev_statuses.cursor::<PathProgress>(());
|
||||
for path in changed_paths.into_iter() {
|
||||
if cursor.seek_forward(&PathTarget::Path(&path), Bias::Left) {
|
||||
changed_path_statuses.push(Edit::Remove(PathKey(path.0)));
|
||||
changed_path_statuses
|
||||
.push(Edit::Remove(PathKey(path.as_ref().clone())));
|
||||
}
|
||||
}
|
||||
changed_path_statuses
|
||||
@@ -5435,10 +5438,8 @@ fn get_permalink_in_rust_registry_src(
|
||||
remote,
|
||||
BuildPermalinkParams::new(
|
||||
&cargo_vcs_info.git.sha1,
|
||||
&RepoPath(
|
||||
RelPath::new(&path, PathStyle::local())
|
||||
.context("invalid path")?
|
||||
.into_arc(),
|
||||
&RepoPath::from_rel_path(
|
||||
&RelPath::new(&path, PathStyle::local()).context("invalid path")?,
|
||||
),
|
||||
Some(selection),
|
||||
),
|
||||
@@ -5640,7 +5641,11 @@ async fn compute_snapshot(
|
||||
let mut events = Vec::new();
|
||||
let branches = backend.branches().await?;
|
||||
let branch = branches.into_iter().find(|branch| branch.is_head);
|
||||
let statuses = backend.status(&[RelPath::empty().into()]).await?;
|
||||
let statuses = backend
|
||||
.status(&[RepoPath::from_rel_path(
|
||||
&RelPath::new(".".as_ref(), PathStyle::local()).unwrap(),
|
||||
)])
|
||||
.await?;
|
||||
let stash_entries = backend.stash_entries().await?;
|
||||
let statuses_by_path = SumTree::from_iter(
|
||||
statuses
|
||||
|
||||
Reference in New Issue
Block a user