diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-03-27 18:15:08 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-03-30 13:45:00 +0200 |
commit | ed9bfe29a1d54a6dca1fa85853457c56108a6183 (patch) | |
tree | dcfa02e41e34cb727855e2d8cdbf0bcb9bbb2fba /src/other_tools/git_operations/git_repo_remote.cpp | |
parent | 0c90ad4bf580a385aa7056298452980b5f8ceb83 (diff) | |
download | justbuild-ed9bfe29a1d54a6dca1fa85853457c56108a6183.tar.gz |
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.
Diffstat (limited to 'src/other_tools/git_operations/git_repo_remote.cpp')
-rw-r--r-- | src/other_tools/git_operations/git_repo_remote.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
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<git_config> 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<git_config> 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<git_config> 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> { 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<git_config>(cfg_ptr, config_closer); |