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: reload index before reading it (#27386)

João Marcos11552cc0bda7
diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs
index 70e370adf9d..139e07901ae 100644
--- a/crates/git/src/repository.rs
+++ b/crates/git/src/repository.rs
@@ -476,12 +476,13 @@ impl GitRepository for RealGitRepository {
let repo = self.repository.clone();
cx.background_spawn(async move {
fn logic(repo: &git2::Repository, path: &RepoPath) -> Result<Option<String>> {
- const STAGE_NORMAL: i32 = 0;
- let index = repo.index()?;
-
// This check is required because index.get_path() unwraps internally :(
check_path_to_repo_path_errors(path)?;
+ let mut index = repo.index()?;
+ index.read(false)?;
+
+ const STAGE_NORMAL: i32 = 0;
let oid = match index.get_path(path, STAGE_NORMAL) {
Some(entry) if entry.mode != GIT_MODE_SYMLINK => entry.id,
_ => return Ok(None),