summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-04-19 15:32:26 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-04-19 15:50:02 +0200
commit7ac10782ca0fcf896137f79cdaa3a3f4e74bdbeb (patch)
tree4c0d4bbbfb7d479e9508fcf4653c5a7e9af54659 /src
parent728f9e810ed3b49a73243b6002e1117a86bad437 (diff)
downloadjustbuild-7ac10782ca0fcf896137f79cdaa3a3f4e74bdbeb.tar.gz
just-mr archive: subdir matters!
When deciding if two archive-based repositories create the same root it is not enough to compare the contents of the archive; it also matters which subdirectory we will take as root. This is especially important, if we take the same archive on the one hand for the code and also the example subdir for testing. Additionally, we cannot ignore the archive type; there are tar archives that are also zip archives, but with different content. (Tar only cares about the initial segment till it finds the two empty blocks; zip has the index at the end and ignores any initial segment that might have been prepended to a valid zip archive.)
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index a490b34a..b2f0fb58 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -40,12 +40,13 @@ struct ArchiveContent {
// Used in callers of ContentCASMap which need extra fields
struct ArchiveRepoInfo {
- ArchiveContent archive; /* key (see ArchiveContent) */
+ ArchiveContent archive;
std::string repo_type;
std::string subdir;
[[nodiscard]] auto operator==(const ArchiveRepoInfo& other) const -> bool {
- return archive.content == other.archive.content;
+ return archive == other.archive && subdir == other.subdir &&
+ repo_type == other.repo_type;
}
};
@@ -70,9 +71,13 @@ template <>
struct hash<ArchiveRepoInfo> {
[[nodiscard]] auto operator()(const ArchiveRepoInfo& ct) const noexcept
-> std::size_t {
- return std::hash<ArchiveContent>{}(ct.archive);
+ size_t seed{};
+ hash_combine<ArchiveContent>(&seed, ct.archive);
+ hash_combine<std::string>(&seed, ct.subdir);
+ hash_combine<std::string>(&seed, ct.repo_type);
+ return seed;
}
};
} // namespace std
-#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_CONTENT_CAS_MAP_HPP \ No newline at end of file
+#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_CONTENT_CAS_MAP_HPP