diff options
author | Sascha Roloff <sascha.roloff@huawei.com> | 2022-07-05 19:46:33 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2022-08-05 14:41:31 +0200 |
commit | 4ce6ec5563c0aa277b455c9c1ded7e8556402c68 (patch) | |
tree | 702382cd10718a84b4340a926b677b180e40dbd1 /src | |
parent | ee6f54124360d8a72b9b545dcc581f3c80d3c8a9 (diff) | |
download | justbuild-4ce6ec5563c0aa277b455c9c1ded7e8556402c68.tar.gz |
Git tree can return size
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/file_system/git_tree.cpp | 7 | ||||
-rw-r--r-- | src/buildtool/file_system/git_tree.hpp | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp index 8d220e30..30c98261 100644 --- a/src/buildtool/file_system/git_tree.cpp +++ b/src/buildtool/file_system/git_tree.cpp @@ -78,6 +78,13 @@ auto GitTree::LookupEntryByPath( return LookupEntryPyPath(*this, resolved.begin(), resolved.end()); } +auto GitTree::Size() const noexcept -> std::optional<std::size_t> { + if (auto header = cas_->ReadHeader(raw_id_)) { + return header->first; + } + return std::nullopt; +} + auto GitTreeEntry::Blob() const noexcept -> std::optional<std::string> { if (not IsBlob()) { return std::nullopt; diff --git a/src/buildtool/file_system/git_tree.hpp b/src/buildtool/file_system/git_tree.hpp index eb1c2147..25218634 100644 --- a/src/buildtool/file_system/git_tree.hpp +++ b/src/buildtool/file_system/git_tree.hpp @@ -47,6 +47,7 @@ class GitTree { [[nodiscard]] auto end() const noexcept { return entries_.end(); } [[nodiscard]] auto Hash() const noexcept { return ToHexString(raw_id_); } [[nodiscard]] auto RawHash() const noexcept { return raw_id_; } + [[nodiscard]] auto Size() const noexcept -> std::optional<std::size_t>; private: gsl::not_null<GitCASPtr> cas_; |