summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/git_repo.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-04-04 12:57:31 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-04-10 14:06:21 +0200
commit1b0aa19f20d102bf96ada7a1e77843eeef20985c (patch)
treea557bddd21d7482429563aeb2f1720902447920e /src/buildtool/file_system/git_repo.hpp
parent646d52aac3b5e14ae0c2a552987d84f184345178 (diff)
downloadjustbuild-1b0aa19f20d102bf96ada7a1e77843eeef20985c.tar.gz
git_repo: Add blob writer method
Also extends the tests accordingly.
Diffstat (limited to 'src/buildtool/file_system/git_repo.hpp')
-rw-r--r--src/buildtool/file_system/git_repo.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp
index 885ddde1..60353a00 100644
--- a/src/buildtool/file_system/git_repo.hpp
+++ b/src/buildtool/file_system/git_repo.hpp
@@ -263,6 +263,15 @@ class GitRepo {
anon_logger_ptr const& logger) noexcept
-> std::pair<bool, std::optional<std::string>>;
+ /// \brief Write given content as a blob into underlying object database.
+ /// Calling it from a fake repository allows thread-safe use.
+ /// \returns Git ID of the written blob, or nullopt on errors.
+ /// It guarantees the logger is called exactly once with fatal if failure.
+ /// Use with care, especially for large objects.
+ [[nodiscard]] auto WriteBlob(std::string const& content,
+ anon_logger_ptr const& logger) noexcept
+ -> 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.