Skip to content

Commit 2374e00

Browse files
authored
validate path on startup for gix aswell (#2768)
so far we only try to open using the legacy libgit2 based one
1 parent 844a208 commit 2374e00

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

asyncgit/src/sync/utils.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ pub struct Head {
2626

2727
///
2828
pub fn repo_open_error(repo_path: &RepoPath) -> Option<String> {
29-
Repository::open_ext(
29+
if let Err(e) = Repository::open_ext(
3030
repo_path.gitpath(),
3131
RepositoryOpenFlags::FROM_ENV,
3232
Vec::<&Path>::new(),
33+
) {
34+
return Some(e.to_string());
35+
}
36+
37+
gix::ThreadSafeRepository::discover_with_environment_overrides(
38+
repo_path.gitpath(),
3339
)
3440
.map_or_else(|e| Some(e.to_string()), |_| None)
3541
}

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ fn draw(terminal: &mut Terminal, app: &App) -> io::Result<()> {
355355
fn ensure_valid_path(repo_path: &RepoPath) -> Result<()> {
356356
match asyncgit::sync::repo_open_error(repo_path) {
357357
Some(e) => {
358-
log::error!("{e}");
359-
bail!(e)
358+
log::error!("invalid repo path: {e}");
359+
bail!("invalid repo path: {e}")
360360
}
361361
None => Ok(()),
362362
}

0 commit comments

Comments
 (0)