From 27576086dcbb7abdb68d129cc101ff81587a5901 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 27 Feb 2023 16:17:11 +0100 Subject: GitRepo: Add method to check existence of a Git tree --- src/buildtool/file_system/git_repo.hpp | 9 +++++++++ 1 file changed, 9 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 a5a8da7a..eba826d9 100644 --- a/src/buildtool/file_system/git_repo.hpp +++ b/src/buildtool/file_system/git_repo.hpp @@ -186,6 +186,15 @@ class GitRepo { anon_logger_ptr const& logger) noexcept -> std::optional; + /// \brief Check if given tree ID is present in the directory structure of + /// the local repository. + /// Calling it from a fake repository allows thread-safe use. + /// Returns a status of tree presence, or nullopt if failure. + /// It guarantees the logger is called exactly once with fatal if failure. + [[nodiscard]] auto CheckTreeExists(std::string const& tree_id, + anon_logger_ptr const& logger) noexcept + -> std::optional; + private: // IMPORTANT! The GitCAS object must be defined before the repo object to // keep the GitContext alive until cleanup ends. -- cgit v1.2.3