From c99e8ebc4dc12544ad55cd55e13b0bbe49b6cb4c Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Mon, 11 Jul 2022 12:18:29 +0200 Subject: GitCAS: Support reading/creating trees without filesystem IO --- src/buildtool/file_system/git_cas.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/buildtool/file_system/git_cas.hpp') diff --git a/src/buildtool/file_system/git_cas.hpp b/src/buildtool/file_system/git_cas.hpp index df077daf..98ebe8d9 100644 --- a/src/buildtool/file_system/git_cas.hpp +++ b/src/buildtool/file_system/git_cas.hpp @@ -87,6 +87,27 @@ class GitCAS { [[nodiscard]] auto CreateTree(GitCAS::tree_entries_t const& entries) const noexcept -> std::optional; + /// \brief Read entries from tree data (without object db). + /// \param data The tree object as plain data. + /// \param id The object id. + /// \param is_hex_id Specify whether `id` is hex string or raw. + /// \returns The tree entries. + [[nodiscard]] static auto ReadTreeData(std::string const& data, + std::string const& id, + bool is_hex_id = false) noexcept + -> std::optional; + + /// \brief Create a flat shallow (without objects in db) tree and return it. + /// Creates a tree object from the entries without access to the actual + /// blobs. Objects are not required to be available in the underlying object + /// database. It is sufficient to provide the raw object id and and object + /// type for every entry. + /// \param entries The entries to create the tree from. + /// \returns A pair of raw object id and the tree object content. + [[nodiscard]] static auto CreateShallowTree( + GitCAS::tree_entries_t const& entries) noexcept + -> std::optional>; + private: git_odb* odb_{nullptr}; bool initialized_{false}; -- cgit v1.2.3