From 4e8f6ddae974694f893e5a636a5d6b00cc05e775 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 3 Dec 2025 12:56:16 +0100 Subject: [PATCH] git: Fix unwrap in `git2::Index::get_path` (#44059) Fixes ZED-1VR Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/git/src/repository.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 4f11819f1097617a6b416fa8e991072d595db38a..23c5795209c1eda9acbf4fe9f48a4e3de898a89a 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -967,7 +967,15 @@ impl GitRepository for RealGitRepository { index.read(false)?; const STAGE_NORMAL: i32 = 0; - let oid = match index.get_path(path.as_std_path(), STAGE_NORMAL) { + let path = path.as_std_path(); + // `RepoPath` contains a `RelPath` which normalizes `.` into an empty path + // `get_path` unwraps on empty paths though, so undo that normalization here + let path = if path.components().next().is_none() { + ".".as_ref() + } else { + path + }; + let oid = match index.get_path(path, STAGE_NORMAL) { Some(entry) if entry.mode != GIT_MODE_SYMLINK => entry.id, _ => return Ok(None), };