ok/jj
1
0
Fork 0
forked from mirrors/jj

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.
This commit is contained in:
Yuya Nishihara 2023-10-30 19:26:57 +09:00
parent fd187d266f
commit f5a61dc2b7

View file

@ -163,7 +163,13 @@ impl GitBackend {
.context(&target_path) .context(&target_path)
.map_err(GitBackendInitError::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)?; .map_err(GitBackendInitError::OpenRepository)?;
let extra_metadata_store = TableStore::init(extra_path, HASH_LENGTH); let extra_metadata_store = TableStore::init(extra_path, HASH_LENGTH);
Ok(GitBackend::new(repo, extra_metadata_store)) Ok(GitBackend::new(repo, extra_metadata_store))