diff options
-rw-r--r-- | src/buildtool/file_system/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/file_system/git_tree.cpp | 13 | ||||
-rw-r--r-- | test/buildtool/file_system/TARGETS | 1 | ||||
-rw-r--r-- | test/buildtool/file_system/git_tree.test.cpp | 8 |
4 files changed, 14 insertions, 9 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS index 87aa9e2c..d08d8451 100644 --- a/src/buildtool/file_system/TARGETS +++ b/src/buildtool/file_system/TARGETS @@ -103,7 +103,6 @@ [ ["src/buildtool/common", "common"] , ["src/buildtool/logging", "log_level"] , ["src/buildtool/logging", "logging"] - , ["src/utils/cpp", "path"] ] } , "git_context": diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp index ded027c2..ca0727fb 100644 --- a/src/buildtool/file_system/git_tree.cpp +++ b/src/buildtool/file_system/git_tree.cpp @@ -21,7 +21,6 @@ #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" -#include "src/utils/cpp/path.hpp" namespace { @@ -61,8 +60,11 @@ class SymlinksChecker final { std::vector<ArtifactDigest> const& ids) const noexcept -> bool { return std::all_of( ids.begin(), ids.end(), [&cas = cas_](ArtifactDigest const& id) { - auto content = cas.ReadObject(id.hash(), /*is_hex_id=*/true); - return content.has_value() and PathIsNonUpwards(*content); + return cas + .ReadObject(id.hash(), + /*is_hex_id=*/true, + /*as_valid_symlink=*/true) + .has_value(); }); }; @@ -138,7 +140,10 @@ auto GitTreeEntry::Blob() const noexcept -> std::optional<std::string> { if (not IsBlob()) { return std::nullopt; } - return cas_->ReadObject(raw_id_, /*is_hex_id=*/false); + // return only valid blobs + return cas_->ReadObject(raw_id_, + /*is_hex_id=*/false, + /*as_valid_symlink=*/IsSymlinkObject(type_)); } auto GitTreeEntry::Tree(bool ignore_special) const& noexcept diff --git a/test/buildtool/file_system/TARGETS b/test/buildtool/file_system/TARGETS index 141deb42..5062ee29 100644 --- a/test/buildtool/file_system/TARGETS +++ b/test/buildtool/file_system/TARGETS @@ -52,7 +52,6 @@ , ["@", "src", "src/buildtool/file_system", "object_type"] , ["@", "src", "src/utils/cpp", "atomic"] , ["@", "src", "src/utils/cpp", "hex_string"] - , ["@", "src", "src/utils/cpp", "path"] , ["", "catch-main"] , ["utils", "container_matchers"] , ["utils", "shell_quoting"] diff --git a/test/buildtool/file_system/git_tree.test.cpp b/test/buildtool/file_system/git_tree.test.cpp index 18309834..1708ccee 100644 --- a/test/buildtool/file_system/git_tree.test.cpp +++ b/test/buildtool/file_system/git_tree.test.cpp @@ -38,7 +38,6 @@ #include "src/buildtool/file_system/object_type.hpp" #include "src/utils/cpp/atomic.hpp" #include "src/utils/cpp/hex_string.hpp" -#include "src/utils/cpp/path.hpp" #include "test/utils/container_matchers.hpp" #include "test/utils/shell_quoting.hpp" @@ -116,8 +115,11 @@ class SymlinksChecker final { std::vector<ArtifactDigest> const& ids) const noexcept -> bool { return std::all_of( ids.begin(), ids.end(), [&cas = cas_](ArtifactDigest const& id) { - auto content = cas.ReadObject(id.hash(), /*is_hex_id=*/true); - return content.has_value() and PathIsNonUpwards(*content); + return cas + .ReadObject(id.hash(), + /*is_hex_id=*/true, + /*as_valid_symlink=*/true) + .has_value(); }); }; |