diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-06-13 13:30:13 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-06-13 13:30:13 +0200 |
commit | 454cfcf66efc6ff5f42253431c6033e1e21044cf (patch) | |
tree | dd19c080220547807b3c3c916ca1a12cc6eabcd6 /src/buildtool/file_system/git_tree.cpp | |
parent | f5c12e59e34107f1fc16349d843a8f64d7dd5459 (diff) | |
download | justbuild-454cfcf66efc6ff5f42253431c6033e1e21044cf.tar.gz |
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.
Diffstat (limited to 'src/buildtool/file_system/git_tree.cpp')
-rw-r--r-- | src/buildtool/file_system/git_tree.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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 <sstream> #include "src/buildtool/logging/logger.hpp" +#include "src/utils/cpp/hex_string.hpp" extern "C" { #include <git2.h> @@ -113,7 +114,11 @@ auto GitTree::Read(std::filesystem::path const& repo_path, auto GitTree::Read(gsl::not_null<GitCASPtr> const& cas, std::string const& tree_id) noexcept -> std::optional<GitTree> { - 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<GitCASPtr> 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<GitTree> const& { if (IsTree() and (obj = cas_->ReadObject(raw_id_))) { if (auto entries = ParseRawTreeObject(cas_, *obj)) { ptr = std::make_shared<std::optional<GitTree>>( - GitTree{cas_, std::move(*entries)}); + GitTree{cas_, std::move(*entries), raw_id_}); } } tree_cached_.store(ptr); |