diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2022-08-29 11:35:15 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2022-12-21 14:41:57 +0100 |
commit | 1f344bd93258fac03b6ea82c15dd5dad41ee20fa (patch) | |
tree | a6696ca58ec9da63d4e1829bb2163c4e60811438 /src/buildtool/file_system/git_tree.cpp | |
parent | af20b222322d943595cd580404eda7be7a0b5ba4 (diff) | |
download | justbuild-1f344bd93258fac03b6ea82c15dd5dad41ee20fa.tar.gz |
Git CAS: Move Git tree ops to fake repo wrapper class
Diffstat (limited to 'src/buildtool/file_system/git_tree.cpp')
-rw-r--r-- | src/buildtool/file_system/git_tree.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp index 6e65ecd6..db391b7e 100644 --- a/src/buildtool/file_system/git_tree.cpp +++ b/src/buildtool/file_system/git_tree.cpp @@ -68,8 +68,14 @@ auto GitTree::Read(gsl::not_null<GitCASPtr> const& cas, std::string const& tree_id) noexcept -> std::optional<GitTree> { if (auto raw_id = FromHexString(tree_id)) { - if (auto entries = cas->ReadTree(*raw_id)) { - return GitTree::FromEntries(cas, std::move(*entries), *raw_id); + auto repo = GitRepo::Open(cas); + if (repo != std::nullopt) { + if (auto entries = repo->ReadTree(*raw_id)) { + return GitTree::FromEntries(cas, std::move(*entries), *raw_id); + } + } + else { + return ::std::nullopt; } } return std::nullopt; @@ -113,7 +119,11 @@ auto GitTreeEntry::Blob() const noexcept -> std::optional<std::string> { auto GitTreeEntry::Tree() const& noexcept -> std::optional<GitTree> const& { return tree_cached_.SetOnceAndGet([this]() -> std::optional<GitTree> { if (IsTree()) { - if (auto entries = cas_->ReadTree(raw_id_)) { + auto repo = GitRepo::Open(cas_); + if (repo == std::nullopt) { + return std::nullopt; + } + if (auto entries = repo->ReadTree(raw_id_)) { return GitTree::FromEntries(cas_, std::move(*entries), raw_id_); } } |