Skip to content

Commit

Permalink
git_backend: open just-initialized repo with canonicalized path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yuja committed Oct 31, 2023
1 parent cfbcc90 commit aa4d385
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/src/git_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit aa4d385

Please sign in to comment.