summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/git_repo.hpp
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-06-27 17:22:32 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2024-06-28 11:24:09 +0200
commited7e81b9aefaa47e61983d14c2447bbd1f5c95c5 (patch)
tree366dc9ab8809cc05f4354c2007bd47281a7c2974 /src/buildtool/file_system/git_repo.hpp
parent956ed669cf71d1ee74dbb573c542a7565c3a90d3 (diff)
downloadjustbuild-ed7e81b9aefaa47e61983d14c2447bbd1f5c95c5.tar.gz
Use (un)expected for Git repo
Diffstat (limited to 'src/buildtool/file_system/git_repo.hpp')
-rw-r--r--src/buildtool/file_system/git_repo.hpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp
index 54706e41..d43a85ec 100644
--- a/src/buildtool/file_system/git_repo.hpp
+++ b/src/buildtool/file_system/git_repo.hpp
@@ -21,11 +21,12 @@
#include <string>
#include <unordered_map>
#include <utility> // std::move
-#include <variant>
#include <vector>
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/file_system/git_cas.hpp"
+#include "src/buildtool/file_system/git_types.hpp"
+#include "src/utils/cpp/expected.hpp"
extern "C" {
struct git_repository;
@@ -194,15 +195,12 @@ class GitRepo {
/// \brief Get the tree id of a subtree given the root commit
/// Calling it from a fake repository allows thread-safe use.
- /// Returns an error + data union, where at index 0 is a flag stating the
- /// nature of the error on failure (true is fatal, false is non-fatal, i.e.,
- /// commit not found), and at index 1 is the subtree hash on success.
- /// It guarantees the logger is called exactly once with fatal if failure.
+ /// Returns the subtree hash on success or an unexpected error.
[[nodiscard]] auto GetSubtreeFromCommit(
std::string const& commit,
std::string const& subdir,
anon_logger_ptr const& logger) noexcept
- -> std::variant<bool, std::string>;
+ -> expected<std::string, GitLookupError>;
/// \brief Get the tree id of a subtree given the root tree hash
/// Calling it from a fake repository allows thread-safe use.