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:
@@ -272,7 +272,7 @@ impl GitRepository for FakeGitRepository {
|
||||
.ok()
|
||||
.map(|content| String::from_utf8(content).unwrap())?;
|
||||
let repo_path = RelPath::new(repo_path, PathStyle::local()).ok()?;
|
||||
Some((repo_path.into(), (content, is_ignored)))
|
||||
Some((RepoPath::from_rel_path(&repo_path), (content, is_ignored)))
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -436,7 +436,7 @@ impl GitRepository for FakeGitRepository {
|
||||
state
|
||||
.blames
|
||||
.get(&path)
|
||||
.with_context(|| format!("failed to get blame for {:?}", path.0))
|
||||
.with_context(|| format!("failed to get blame for {:?}", path))
|
||||
.cloned()
|
||||
})
|
||||
}
|
||||
|
||||
+2
-1
@@ -1792,7 +1792,8 @@ impl FakeFs {
|
||||
for (path, content) in workdir_contents {
|
||||
use util::{paths::PathStyle, rel_path::RelPath};
|
||||
|
||||
let repo_path: RepoPath = RelPath::new(path.strip_prefix(&workdir_path).unwrap(), PathStyle::local()).unwrap().into();
|
||||
let repo_path = RelPath::new(path.strip_prefix(&workdir_path).unwrap(), PathStyle::local()).unwrap();
|
||||
let repo_path = RepoPath::from_rel_path(&repo_path);
|
||||
let status = statuses
|
||||
.iter()
|
||||
.find_map(|(p, status)| (*p == repo_path.as_unix_str()).then_some(status));
|
||||
|
||||
Reference in New Issue
Block a user