From 454cfcf66efc6ff5f42253431c6033e1e21044cf Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 13 Jun 2022 13:30:13 +0200 Subject: Include raw identifier to GitTree In this way, we have it available when needed, e.g., to get identifers for file roots or to get whole trees as source artifacts. --- src/buildtool/file_system/git_tree.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/buildtool/file_system/git_tree.cpp') diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp index 1805961c..98281707 100644 --- a/src/buildtool/file_system/git_tree.cpp +++ b/src/buildtool/file_system/git_tree.cpp @@ -3,6 +3,7 @@ #include #include "src/buildtool/logging/logger.hpp" +#include "src/utils/cpp/hex_string.hpp" extern "C" { #include @@ -113,7 +114,11 @@ auto GitTree::Read(std::filesystem::path const& repo_path, auto GitTree::Read(gsl::not_null const& cas, std::string const& tree_id) noexcept -> std::optional { - auto obj = cas->ReadObject(tree_id, /*is_hex_id=*/true); + auto raw_id = FromHexString(tree_id); + if (not raw_id) { + return std::nullopt; + } + auto obj = cas->ReadObject(*raw_id); if (not obj) { return std::nullopt; } @@ -121,7 +126,7 @@ auto GitTree::Read(gsl::not_null const& cas, if (not entries) { return std::nullopt; } - return GitTree{cas, std::move(*entries)}; + return GitTree{cas, std::move(*entries), std::move(*raw_id)}; } auto GitTree::LookupEntryByName(std::string const& name) const noexcept @@ -157,7 +162,7 @@ auto GitTreeEntry::Tree() const& noexcept -> std::optional const& { if (IsTree() and (obj = cas_->ReadObject(raw_id_))) { if (auto entries = ParseRawTreeObject(cas_, *obj)) { ptr = std::make_shared>( - GitTree{cas_, std::move(*entries)}); + GitTree{cas_, std::move(*entries), raw_id_}); } } tree_cached_.store(ptr); -- cgit v1.2.3