From 359747ec797498cd43b9b7c3fdb23cb272e66b2a Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 21 May 2019 20:25:59 -0400 Subject: [PATCH 1/2] Fix XMD comparison Comparison of the XMDs were accidentally returning the opposite truth value. Signed-off-by: Stephen Gallagher --- modulemd/v2/modulemd-module-stream-v1.c | 2 +- modulemd/v2/modulemd-module-stream-v2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modulemd/v2/modulemd-module-stream-v1.c b/modulemd/v2/modulemd-module-stream-v1.c index 4c26f33be..34df203be 100644 --- a/modulemd/v2/modulemd-module-stream-v1.c +++ b/modulemd/v2/modulemd-module-stream-v1.c @@ -1075,7 +1075,7 @@ modulemd_module_stream_v1_equals (ModulemdModuleStream *self_1, if (v1_self_1->xmd == NULL || v1_self_2->xmd == NULL) return FALSE; - if (g_variant_equal (v1_self_1->xmd, v1_self_2->xmd) != 0) + if (!g_variant_equal (v1_self_1->xmd, v1_self_2->xmd)) return FALSE; return TRUE; diff --git a/modulemd/v2/modulemd-module-stream-v2.c b/modulemd/v2/modulemd-module-stream-v2.c index 24b72a860..ca0beae47 100644 --- a/modulemd/v2/modulemd-module-stream-v2.c +++ b/modulemd/v2/modulemd-module-stream-v2.c @@ -231,7 +231,7 @@ modulemd_module_stream_v2_equals (ModulemdModuleStream *self_1, if (v2_self_1->xmd == NULL || v2_self_2->xmd == NULL) return FALSE; - if (g_variant_equal (v2_self_1->xmd, v2_self_2->xmd) != 0) + if (!g_variant_equal (v2_self_1->xmd, v2_self_2->xmd)) return FALSE; return TRUE; From 10e0db0fe2ccd00dd9637311a822c5a38f1cef50 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 21 May 2019 20:27:47 -0400 Subject: [PATCH 2/2] Check full stream equality when deduplicating Previously, we assumed that any two streams having the same NSVCA were identical. Now we can actually test for full equality before dropping one while deduplicating. Note that this will result in a hard failure if they aren't identical, because this means that the enabled repositories are providing conflicting data. Fixes: https://github.com/fedora-modularity/libmodulemd/issues/188 Signed-off-by: Stephen Gallagher --- modulemd/v2/modulemd-module.c | 15 +++++++++++---- modulemd/v2/tests/test-modulemd-merger.c | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modulemd/v2/modulemd-module.c b/modulemd/v2/modulemd-module.c index 699e8808a..e6ac372fc 100644 --- a/modulemd/v2/modulemd-module.c +++ b/modulemd/v2/modulemd-module.c @@ -329,10 +329,17 @@ modulemd_module_add_stream (ModulemdModule *self, * favor of the new one. */ - /* TODO: Do a full equality check on the two ModuleStreams once - * https://github.com/fedora-modularity/libmodulemd/issues/186 is - * fixed. - */ + if (!modulemd_module_stream_equals (old, stream)) + { + /* The two streams have matching NSVCA, but differ in content */ + g_set_error (error, + MODULEMD_ERROR, + MODULEMD_ERROR_VALIDATE, + "Encountered two streams with matching NSVCA %s but " + "differing content", + modulemd_module_stream_get_NSVCA_as_string (stream)); + return MD_MODULESTREAM_VERSION_ERROR; + } /* First, drop the existing stream */ g_ptr_array_remove (self->streams, old); diff --git a/modulemd/v2/tests/test-modulemd-merger.c b/modulemd/v2/tests/test-modulemd-merger.c index bac730670..e46b4d844 100644 --- a/modulemd/v2/tests/test-modulemd-merger.c +++ b/modulemd/v2/tests/test-modulemd-merger.c @@ -90,8 +90,8 @@ merger_test_deduplicate (CommonMmdTestFixture *fixture, /* Resolve the merge, which should deduplicate all entries */ merged_index = modulemd_module_index_merger_resolve (merger, &error); + g_assert_no_error (error); g_assert_nonnull (merged_index); - g_assert_null (error); deduplicated = modulemd_module_index_dump_to_string (merged_index, &error); g_assert_nonnull (deduplicated);