From cc5636adb95d6e0de1ff7858b317d7ed319c0ee8 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 4 Jul 2023 16:13:30 +0200 Subject: Git: Fix handling of symlinks in tree artifacts The introduction of non-upwards symlinks as first-class objects should have updated the handling of known git tree artifacts containing symlinks. In particular, one should consider trees in their entirety when uploading (irrespective of the ignore_special flag), and git trees should only be reported as known only if the ignore_special flag is set to false. --- src/buildtool/file_system/file_root.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/buildtool/file_system/file_root.hpp') diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index b2768471..b332f9cd 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -213,8 +213,7 @@ class FileRoot { } /// \brief Retrieve a root tree as a KNOWN artifact. - /// User should know whether this root tree is symlink free and only - /// call this function accordingly. + /// Only succeeds if no entries have to be ignored. [[nodiscard]] auto AsKnownTree(std::string const& repository) const noexcept -> std::optional { if (Compatibility::IsCompatible()) { @@ -223,6 +222,10 @@ class FileRoot { if (std::holds_alternative(data_)) { try { auto const& data = std::get(data_); + // check if tree is ignore_special + if (data->RawHash().empty()) { + return std::nullopt; + } auto const& id = data->Hash(); auto const& size = data->Size(); if (size) { @@ -502,11 +505,10 @@ class FileRoot { } /// \brief Read a root tree based on its ID. - /// User should know whether the desired tree is symlink free and only call - /// this function accordingly. + /// This should include all valid entry types. [[nodiscard]] auto ReadTree(std::string const& tree_id) const noexcept -> std::optional { - if (std::holds_alternative(root_) and not ignore_special_) { + if (std::holds_alternative(root_)) { try { auto const& cas = std::get(root_).cas; return GitTree::Read(cas, tree_id); -- cgit v1.2.3