summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/git_cas.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2022-08-24 16:49:21 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2022-12-20 16:02:13 +0100
commit6d938afb02d276afeb0e56689a9c3e8cb756ec37 (patch)
tree6ee6b62130610ecc9f0e71d64b93d51a484468e0 /src/buildtool/file_system/git_cas.hpp
parentb8e5ec6a4a28163e8f9ff5b23c3ebf1df3d73720 (diff)
downloadjustbuild-6d938afb02d276afeb0e56689a9c3e8cb756ec37.tar.gz
Git CAS: Add a Git context class to maintain the libgit2 state
Diffstat (limited to 'src/buildtool/file_system/git_cas.hpp')
-rw-r--r--src/buildtool/file_system/git_cas.hpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/buildtool/file_system/git_cas.hpp b/src/buildtool/file_system/git_cas.hpp
index 26acc52f..3670d188 100644
--- a/src/buildtool/file_system/git_cas.hpp
+++ b/src/buildtool/file_system/git_cas.hpp
@@ -21,6 +21,7 @@
#include <unordered_map>
#include <vector>
+#include "src/buildtool/file_system/git_context.hpp"
#include "src/buildtool/file_system/object_type.hpp"
extern "C" {
@@ -30,7 +31,7 @@ using git_odb = struct git_odb;
class GitCAS;
using GitCASPtr = std::shared_ptr<GitCAS const>;
-/// \brief Git CAS that maintains its own libgit2 global state.
+/// \brief Git CAS that maintains its Git context.
class GitCAS {
public:
// Stores the data for defining a single Git tree entry, which consists of
@@ -55,7 +56,7 @@ class GitCAS {
static auto Open(std::filesystem::path const& repo_path) noexcept
-> GitCASPtr;
- GitCAS() noexcept;
+ GitCAS() noexcept = default;
~GitCAS() noexcept;
// prohibit moves and copies
@@ -123,8 +124,9 @@ class GitCAS {
-> std::optional<std::pair<std::string, std::string>>;
private:
+ // IMPORTANT: the GitContext needs to be initialized before any git object!
+ GitContext git_context_{}; // maintains a Git context while CAS is alive
git_odb* odb_{nullptr};
- bool initialized_{false};
[[nodiscard]] auto OpenODB(std::filesystem::path const& repo_path) noexcept
-> bool;