From 9e67da79d72e52fdef5bbc4fc08991dfe9ddf155 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Wed, 29 Oct 2025 21:48:11 +0100 Subject: [PATCH] validate path on startup for gix aswell so far we only try to open using the legacy libgit2 based one --- asyncgit/src/sync/utils.rs | 8 +++++++- src/main.rs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs index 3250de69e9..148e29baa9 100644 --- a/asyncgit/src/sync/utils.rs +++ b/asyncgit/src/sync/utils.rs @@ -26,10 +26,16 @@ pub struct Head { /// pub fn repo_open_error(repo_path: &RepoPath) -> Option { - Repository::open_ext( + if let Err(e) = Repository::open_ext( repo_path.gitpath(), RepositoryOpenFlags::FROM_ENV, Vec::<&Path>::new(), + ) { + return Some(e.to_string()); + } + + gix::ThreadSafeRepository::discover_with_environment_overrides( + repo_path.gitpath(), ) .map_or_else(|e| Some(e.to_string()), |_| None) } diff --git a/src/main.rs b/src/main.rs index d1c7668ae7..72165b083b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -355,8 +355,8 @@ fn draw(terminal: &mut Terminal, app: &App) -> io::Result<()> { fn ensure_valid_path(repo_path: &RepoPath) -> Result<()> { match asyncgit::sync::repo_open_error(repo_path) { Some(e) => { - log::error!("{e}"); - bail!(e) + log::error!("invalid repo path: {e}"); + bail!("invalid repo path: {e}") } None => Ok(()), }