From 03a47642ab3e32b561d36fb192bca76ccc677b59 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 30 Nov 2023 10:03:06 +0100 Subject: FileRoot: Fix content description for ignore-special roots Ignore-special git-tree-based roots are still content defined, so one should use the correct marker in the JSON description of the root that will be stored in the repository description of target cache keys. This commit fixes the issue and improves documentation. --- src/buildtool/file_system/file_root.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 4d07f938..4d71fe23 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -340,26 +340,31 @@ class FileRoot { return std::nullopt; } - // Return a complete description of the content of this root, if - // content-fixed. + /// \brief Return a complete description of the content of this root, if + /// content fixed. This includes absent roots and any git-tree-based + /// ignore-special roots. [[nodiscard]] auto ContentDescription() const noexcept -> std::optional { try { if (std::holds_alternative(root_)) { nlohmann::json j; - // ignore-special git-tree-based roots are still content-fixed - j.push_back(kGitTreeMarker); + j.push_back(ignore_special_ ? kGitTreeIgnoreSpecialMarker + : kGitTreeMarker); j.push_back(std::get(root_).tree->Hash()); return j; } if (std::holds_alternative(root_)) { nlohmann::json j; - // ignore-special git-tree-based roots are still content-fixed - j.push_back(kGitTreeMarker); + j.push_back(ignore_special_ ? kGitTreeIgnoreSpecialMarker + : kGitTreeMarker); j.push_back(std::get(root_)); return j; } - } catch (...) { + } catch (std::exception const& ex) { + Logger::Log(LogLevel::Debug, + "Retrieving the description of a content-fixed root " + "failed unexpectedly with:\n{}", + ex.what()); } return std::nullopt; } -- cgit v1.2.3