Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git: Optimize git HEAD state resolution (#59044)

Lukas Geiger772668289847
diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs
index d8986cd2416..c2522576e85 100644
--- a/crates/fs/src/fake_git_repo.rs
+++ b/crates/fs/src/fake_git_repo.rs
@@ -264,14 +264,14 @@ impl GitRepository for FakeGitRepository {
}
fn show(&self, commit: String) -> BoxFuture<'_, Result<CommitDetails>> {
- async {
+ self.with_state_async(false, move |state| {
+ let sha = state.refs.get(&commit).cloned().unwrap_or(commit);
Ok(CommitDetails {
- sha: commit.into(),
+ sha: sha.into(),
message: "initial commit".into(),
..Default::default()
})
- }
- .boxed()
+ })
}
fn reset(
diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs
index ef67a89b69a..0af840fbbeb 100644
--- a/crates/project/src/git_store.rs
+++ b/crates/project/src/git_store.rs
@@ -9888,12 +9888,7 @@ async fn compute_snapshot(
};
let head_commit_future = {
let backend = backend.clone();
- async move {
- match backend.head_sha().await {
- Some(head_sha) => backend.show(head_sha).await.log_err(),
- None => None,
- }
- }
+ async move { backend.show("HEAD".to_string()).await.ok() }
};
let worktrees_future = {
let backend = backend.clone();