summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-30 10:03:06 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-30 11:26:22 +0100
commit03a47642ab3e32b561d36fb192bca76ccc677b59 (patch)
tree0c1c8770324d196469e0cc269051ecfea1f6c73f
parent9f9fba8bf21b4614c96b67ab8b93bd6c69051fc1 (diff)
downloadjustbuild-03a47642ab3e32b561d36fb192bca76ccc677b59.tar.gz
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.
-rw-r--r--src/buildtool/file_system/file_root.hpp19
1 files changed, 12 insertions, 7 deletions
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<nlohmann::json> {
try {
if (std::holds_alternative<git_root_t>(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<git_root_t>(root_).tree->Hash());
return j;
}
if (std::holds_alternative<absent_root_t>(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<absent_root_t>(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;
}