From 1f997bfa62e5feac45f84fbc2ae7ee62ffd40f3d Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 25 Sep 2023 15:01:52 +0200 Subject: GitRepo: Add blob existence checker Also fixes a small typo in tree existence checker log messages. --- src/buildtool/file_system/git_repo.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/buildtool/file_system/git_repo.hpp') diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp index b2e12934..7314289a 100644 --- a/src/buildtool/file_system/git_repo.hpp +++ b/src/buildtool/file_system/git_repo.hpp @@ -219,6 +219,17 @@ class GitRepo { anon_logger_ptr const& logger) noexcept -> std::optional; + /// \brief Check if given blob ID is present in the directory structure of + /// the local repository and try to return it. + /// Calling it from a fake repository allows thread-safe use. + /// Returns a pair of a success flag, stating that no errors occurred while + /// performing the libgit2 calls, and an optional string containing the + /// content of the blob, if the blob is found. It guarantees the logger is + /// called exactly once with fatal if failure. + [[nodiscard]] auto TryReadBlob(std::string const& blob_id, + anon_logger_ptr const& logger) noexcept + -> std::pair>; + /// \brief Get the object info related to a given path inside a Git tree. /// Unlike GetSubtreeFromTree, we here ignore errors and only return a value /// when all is successful. -- cgit v1.2.3