Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Perform only one git statuses call when reloading a git repo after it changes
Max Brunsfeldb9e00747932d
diff --git a/crates/fs/src/repository.rs b/crates/fs/src/repository.rsindex ed9aa85a89b..3826dae2aa7 100644--- a/crates/fs/src/repository.rs+++ b/crates/fs/src/repository.rs@@ -33,6 +33,7 @@ pub trait GitRepository: Send {fn statuses(&self) -> Option<TreeMap<RepoPath, GitFileStatus>>;fn status(&self, path: &RepoPath) -> Result<Option<GitFileStatus>>;+fn branches(&self) -> Result<Vec<Branch>> {Ok(vec![])}diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rsindex b113af34ad4..a1730fd365f 100644--- a/crates/project/src/worktree.rs+++ b/crates/project/src/worktree.rs@@ -2023,6 +2023,9 @@ impl LocalSnapshot {) -> Vec<Arc<Path>> {let mut changes = vec![];let mut edits = vec![];++ let statuses = repo_ptr.statuses();+for mut entry in self.descendent_entries(false, false, &work_directory.0).cloned()@@ -2030,10 +2033,8 @@ impl LocalSnapshot {let Ok(repo_path) = entry.path.strip_prefix(&work_directory.0) else {continue;};- let git_file_status = repo_ptr- .status(&RepoPath(repo_path.into()))- .log_err()- .flatten();+ let repo_path = RepoPath(repo_path.to_path_buf());+ let git_file_status = statuses.as_ref().and_then(|s| s.get(&repo_path).copied());if entry.git_status != git_file_status {entry.git_status = git_file_status;changes.push(entry.path.clone());