From f5a61dc2b7257aeca530b72d6fb2f8f21f749a08 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 30 Oct 2023 19:26:57 +0900 Subject: [PATCH] git_backend: open just-initialized repo with canonicalized path Otherwise, the initialized repo could have a different work-dir path than the load()-ed one. libgit2 appears to do some normalization somewhere, but gix won't. --- lib/src/git_backend.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index f195db86c..404db5265 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -163,7 +163,13 @@ impl GitBackend { .context(&target_path) .map_err(GitBackendInitError::Path)?; }; - let repo = git2::Repository::open(store_path.join(git_repo_path)) + let canonical_git_repo_path = { + let path = store_path.join(git_repo_path); + path.canonicalize() + .context(&path) + .map_err(GitBackendInitError::Path)? + }; + let repo = git2::Repository::open(canonical_git_repo_path) .map_err(GitBackendInitError::OpenRepository)?; let extra_metadata_store = TableStore::init(extra_path, HASH_LENGTH); Ok(GitBackend::new(repo, extra_metadata_store))