From 1924d2b1fb6004cf6c4cbc49359f00edb8374956 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Sat, 2 May 2026 05:05:03 -0700 Subject: [PATCH] git: skip status entries with non-UTF-8 paths instead of panicking Signed-off-by: SAY-5 --- src/git.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/git.rs b/src/git.rs index aac48ca69..f8fde509e 100644 --- a/src/git.rs +++ b/src/git.rs @@ -60,8 +60,14 @@ impl GitCache { match repo.statuses(None) { Ok(status_list) => { for status_entry in status_list.iter() { + // git2-rs returns `None` from `.path()` when the filename + // bytes from libgit2 are not valid UTF-8. Skip those rather + // than panicking; the file still appears in the listing, + // just without a Git status indicator. + let Some(str_path) = status_entry.path() else { + continue; + }; // git2-rs provides / separated path even on Windows. We have to rebuild it - let str_path = status_entry.path().unwrap(); let path: PathBuf = str_path.split('/').collect::>().iter().collect(); let path = workdir.join(path);