validate path on startup for gix aswell (#2768)

so far we only try to open using the legacy libgit2 based one
This commit is contained in:
extrawurst 2025-10-29 22:07:46 +01:00 committed by GitHub
parent 844a208506
commit 2374e00302
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -26,10 +26,16 @@ pub struct Head {
///
pub fn repo_open_error(repo_path: &RepoPath) -> Option<String> {
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)
}

View file

@ -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(()),
}