summaryrefslogtreecommitdiff
path: root/src/buildtool
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool')
-rw-r--r--src/buildtool/file_system/git_tree.cpp27
-rw-r--r--src/buildtool/file_system/git_tree.hpp5
2 files changed, 20 insertions, 12 deletions
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp
index ca0727fb..3b9f3a8e 100644
--- a/src/buildtool/file_system/git_tree.cpp
+++ b/src/buildtool/file_system/git_tree.cpp
@@ -86,14 +86,19 @@ auto GitTree::Read(std::filesystem::path const& repo_path,
auto GitTree::Read(gsl::not_null<GitCASPtr> const& cas,
std::string const& tree_id,
- bool ignore_special) noexcept -> std::optional<GitTree> {
+ bool ignore_special,
+ bool skip_checks) noexcept -> std::optional<GitTree> {
if (auto raw_id = FromHexString(tree_id)) {
auto repo = GitRepo::Open(cas);
if (repo != std::nullopt) {
- if (auto entries = repo->ReadTree(*raw_id,
- SymlinksChecker{cas},
- /*is_hex_id=*/false,
- ignore_special)) {
+ auto entries =
+ skip_checks ? repo->ReadDirectTree(
+ *raw_id, /*is_hex_id=*/false, ignore_special)
+ : repo->ReadTree(*raw_id,
+ SymlinksChecker{cas},
+ /*is_hex_id=*/false,
+ ignore_special);
+ if (entries) {
// NOTE: the raw_id value is NOT recomputed when
// ignore_special==true.
return GitTree::FromEntries(
@@ -155,11 +160,13 @@ auto GitTreeEntry::Tree(bool ignore_special) const& noexcept
if (repo == std::nullopt) {
return std::nullopt;
}
-
- if (auto entries = repo->ReadTree(raw_id_,
- SymlinksChecker{cas_},
- /*is_hex_id=*/false,
- ignore_special)) {
+ auto entries = repo->ReadTree(raw_id_,
+ SymlinksChecker{cas_},
+ /*is_hex_id=*/false,
+ ignore_special);
+ if (entries) {
+ // NOTE: the raw_id value is NOT recomputed when
+ // ignore_special==true.
return GitTree::FromEntries(
cas_, std::move(*entries), raw_id_, ignore_special);
}
diff --git a/src/buildtool/file_system/git_tree.hpp b/src/buildtool/file_system/git_tree.hpp
index 45c875d6..ccdb5803 100644
--- a/src/buildtool/file_system/git_tree.hpp
+++ b/src/buildtool/file_system/git_tree.hpp
@@ -53,11 +53,13 @@ class GitTree {
/// \param cas Git CAS that contains the tree id.
/// \param tree_id Tree id as as hex string.
/// \param ignore_special If set, treat symlinks as absent.
+ /// \param skip_checks If set, skip any symlinks checks.
/// NOTE: If ignore_special==true, the stored entries might differ from the
/// actual tree, as some filesystem entries get skipped.
[[nodiscard]] static auto Read(gsl::not_null<GitCASPtr> const& cas,
std::string const& tree_id,
- bool ignore_special = false) noexcept
+ bool ignore_special = false,
+ bool skip_checks = false) noexcept
-> std::optional<GitTree>;
/// \brief Lookup by dir entry name. '.' and '..' are not allowed.
@@ -147,7 +149,6 @@ class GitTreeEntry {
[[nodiscard]] auto IsTree() const noexcept { return IsTreeObject(type_); }
[[nodiscard]] auto Blob() const noexcept -> std::optional<std::string>;
- [[nodiscard]] auto Tree(bool) && = delete;
[[nodiscard]] auto Tree(bool ignore_special = false) const& noexcept
-> std::optional<GitTree> const&;