diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-07-04 16:13:30 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-07-11 11:56:33 +0200 |
commit | cc5636adb95d6e0de1ff7858b317d7ed319c0ee8 (patch) | |
tree | 22baea879aeff43882b371b6322dc6b782a4d0b9 /src/buildtool/file_system/file_root.hpp | |
parent | aa7c51883c1be46a5c19b7d3ea6c48edd04b4e77 (diff) | |
download | justbuild-cc5636adb95d6e0de1ff7858b317d7ed319c0ee8.tar.gz |
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.
Diffstat (limited to 'src/buildtool/file_system/file_root.hpp')
-rw-r--r-- | src/buildtool/file_system/file_root.hpp | 12 |
1 files changed, 7 insertions, 5 deletions
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<ArtifactDescription> { if (Compatibility::IsCompatible()) { @@ -223,6 +222,10 @@ class FileRoot { if (std::holds_alternative<tree_t>(data_)) { try { auto const& data = std::get<tree_t>(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<GitTree> { - if (std::holds_alternative<git_root_t>(root_) and not ignore_special_) { + if (std::holds_alternative<git_root_t>(root_)) { try { auto const& cas = std::get<git_root_t>(root_).cas; return GitTree::Read(cas, tree_id); |