diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-09-25 15:01:52 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-11-02 12:06:50 +0100 |
commit | 1f997bfa62e5feac45f84fbc2ae7ee62ffd40f3d (patch) | |
tree | 41dead54bc263add0d304f98f68f20e7b7869ec0 /src/buildtool/file_system/git_repo.hpp | |
parent | 9b32ad44261d5c2ca25c21d879d9dad6b451583f (diff) | |
download | justbuild-1f997bfa62e5feac45f84fbc2ae7ee62ffd40f3d.tar.gz |
GitRepo: Add blob existence checker
Also fixes a small typo in tree existence checker log messages.
Diffstat (limited to 'src/buildtool/file_system/git_repo.hpp')
-rw-r--r-- | src/buildtool/file_system/git_repo.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
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<bool>; + /// \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<bool, std::optional<std::string>>; + /// \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. |