From f0d84b417694430874a150293ffdb1fdc35c7b31 Mon Sep 17 00:00:00 2001 From: Mamoru TASAKA Date: Nov 29 2023 07:43:06 +0000 Subject: Backport upstream patch for testsuite with glibc 2.38.9000-20 qsort behavior change --- diff --git a/notmuch-4f82acc-qsort-stablize.patch b/notmuch-4f82acc-qsort-stablize.patch new file mode 100644 index 0000000..94a846c --- /dev/null +++ b/notmuch-4f82acc-qsort-stablize.patch @@ -0,0 +1,40 @@ +From 4f82acce17ca51b03bea2abe3eefb7c3026138fe Mon Sep 17 00:00:00 2001 +From: David Bremner +Date: Sat, 25 Nov 2023 08:33:52 -0400 +Subject: [PATCH] lib/string_map: simulate stable sorting + +qsort(3) does not promise stability, and recent versions of glibc have +been showing more unstable behaviour [2]. Michael Gruber observed [1] test +breakage due to changing output order for message properties. + +We provide a sorting order of (key,value) pairs that _looks_ stable by +breaking ties based on value if keys are equal. Internally there may +be some instability in the case of duplicate (key,value) pairs, but it +should not be observable via the iterator API. + +[1]: id:CAA19uiSHjVFmwH0pMC7WwDYCOSzu3yqNbuYhu3ZMeNNRh313eA@mail.gmail.com +[2]: id:87msv3i44u.fsf@oldenburg.str.redhat.com +--- + lib/string-map.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/lib/string-map.c b/lib/string-map.c +index e3a81b4f..99bc2ea2 100644 +--- a/lib/string-map.c ++++ b/lib/string-map.c +@@ -86,10 +86,14 @@ _notmuch_string_map_append (notmuch_string_map_t *map, + static int + cmppair (const void *pa, const void *pb) + { ++ int cmp = 0; + notmuch_string_pair_t *a = (notmuch_string_pair_t *) pa; + notmuch_string_pair_t *b = (notmuch_string_pair_t *) pb; + +- return strcmp (a->key, b->key); ++ cmp = strcmp (a->key, b->key); ++ if (cmp == 0) ++ cmp = strcmp (a->value, b->value); ++ return cmp; + } + + static void diff --git a/notmuch.spec b/notmuch.spec index 4a83603..d982a09 100644 --- a/notmuch.spec +++ b/notmuch.spec @@ -46,6 +46,9 @@ Source1: https://notmuchmail.org/releases/notmuch-%{version}.tar.xz.asc Source2: gpgkey-7A18807F100A4570C59684207E4E65C8720B706B.gpg Patch1: 0001-test-allow-to-use-full-scan.patch Patch2: 0002-test-use-NOTMUCH_NEW-consistently.patch +# https://github.com/notmuch/notmuch/commit/4f82acce17ca51b03bea2abe3eefb7c3026138fe +# Patch for testsuite for glibc-2.38.9000-20 qsort behavior change +Patch3: notmuch-4f82acc-qsort-stablize.patch BuildRequires: make BuildRequires: bash-completion