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:
Lukas Wirth
2025-11-10 09:27:51 +00:00
committed by GitHub
parent 359160c8b1
commit 0149de4b54
13 changed files with 90 additions and 84 deletions
@@ -6,6 +6,7 @@ use buffer_diff::DiffHunkStatusKind;
use collections::BTreeMap;
use futures::Future;
use git::repository::RepoPath;
use gpui::{
AnyWindowHandle, App, Context, Entity, Focusable as _, Keystroke, Pixels, Point,
VisualTestContext, Window, WindowHandle, prelude::*,
@@ -334,7 +335,10 @@ impl EditorTestContext {
let path = self.update_buffer(|buffer, _| buffer.file().unwrap().path().clone());
let mut found = None;
fs.with_git_state(&Self::root_path().join(".git"), false, |git_state| {
found = git_state.index_contents.get(&path.into()).cloned();
found = git_state
.index_contents
.get(&RepoPath::from_rel_path(&path))
.cloned();
})
.unwrap();
assert_eq!(expected, found.as_deref());