From ed9bfe29a1d54a6dca1fa85853457c56108a6183 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 27 Mar 2023 18:15:08 +0200 Subject: GitRepo: Guard fake repository odb wrapping In the current libgit2 implementation, a fake repository wrapped around an existing odb is being registered as owner the same way as a normal repository object. Therefore, one has to guard both the creation and destruction of the fake repository against all other git operations that might access the internal cache during this transfer of ownership. --- src/other_tools/git_operations/git_repo_remote.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/other_tools/git_operations/git_repo_remote.cpp') diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp index aa277c3e..0c925cc4 100644 --- a/src/other_tools/git_operations/git_repo_remote.cpp +++ b/src/other_tools/git_operations/git_repo_remote.cpp @@ -148,7 +148,7 @@ auto GitRepoRemote::GetCommitFromRemote(std::shared_ptr cfg, // create remote git_remote* remote_ptr{nullptr}; if (git_remote_create_anonymous( - &remote_ptr, GetRepoRef().get(), repo_url.c_str()) != 0) { + &remote_ptr, GetRepoRef()->Ptr(), repo_url.c_str()) != 0) { (*logger)( fmt::format("Creating anonymous remote for git repository {} " "failed with:\n{}", @@ -279,7 +279,7 @@ auto GitRepoRemote::FetchFromRemote(std::shared_ptr cfg, // create remote from repo git_remote* remote_ptr{nullptr}; if (git_remote_create_anonymous( - &remote_ptr, GetRepoRef().get(), repo_url.c_str()) != 0) { + &remote_ptr, GetRepoRef()->Ptr(), repo_url.c_str()) != 0) { (*logger)(fmt::format("Creating remote {} for git repository {} " "failed with:\n{}", repo_url, @@ -300,7 +300,7 @@ auto GitRepoRemote::FetchFromRemote(std::shared_ptr cfg, if (not cfg) { // get config snapshot of current repo git_config* cfg_ptr{nullptr}; - if (git_repository_config_snapshot(&cfg_ptr, GetRepoRef().get()) != + if (git_repository_config_snapshot(&cfg_ptr, GetRepoRef()->Ptr()) != 0) { (*logger)(fmt::format("Retrieving config object in fetch from " "remote failed with:\n{}", @@ -621,7 +621,7 @@ auto GitRepoRemote::FetchViaTmpRepo(std::filesystem::path const& tmp_dir, auto GitRepoRemote::GetConfigSnapshot() const -> std::shared_ptr { git_config* cfg_ptr{nullptr}; - if (git_repository_config_snapshot(&cfg_ptr, GetRepoRef().get()) != 0) { + if (git_repository_config_snapshot(&cfg_ptr, GetRepoRef()->Ptr()) != 0) { return nullptr; } return std::shared_ptr(cfg_ptr, config_closer); -- cgit v1.2.3