]> git.notmuchmail.org Git - notmuch/commitdiff
lib: break reference loop by choosing arbitrary top level msg
authorDavid Bremner <david@tethera.net>
Sat, 14 Apr 2018 01:08:05 +0000 (22:08 -0300)
committerDavid Bremner <david@tethera.net>
Fri, 20 Apr 2018 14:23:31 +0000 (11:23 -0300)
Other parts of notmuch (e.g. notmuch show) expect each thread to
contain at least one top level message, and crash if this expectation
is not met.

lib/thread.cc
test/T050-new.sh

index 3561b27f743976d2c2d1918d33fc2a8d33469c74..dbac002fd7130c4c7559dcf96fbb9b90bdab2487 100644 (file)
@@ -397,7 +397,13 @@ _resolve_thread_relationships (notmuch_thread_t *thread)
     for (node = thread->message_list->head; node; node = node->next) {
        message = node->message;
        in_reply_to = _notmuch_message_get_in_reply_to (message);
-       if (in_reply_to && strlen (in_reply_to) &&
+       /*
+        * if we reach the end of the list without finding a top-level
+        * message, that means the thread is a cycle (or set of
+        * cycles) and any message can be considered top-level
+        */
+       if ((thread->toplevel_list->head || node->next) &&
+            in_reply_to && strlen (in_reply_to) &&
            g_hash_table_lookup_extended (thread->message_hash,
                                          in_reply_to, NULL,
                                          (void **) &parent))
index b98549781d5302ec04d204fde1d2c24d36017ec7..f3bfe7b159ab042d163dd1f22447948de4aafb14 100755 (executable)
@@ -356,7 +356,6 @@ test_expect_equal_file EXPECTED OUTPUT
 
 add_email_corpus broken
 test_begin_subtest "reference loop does not crash"
-test_subtest_known_broken
 test_expect_code 0 "notmuch show --format=json id:mid-loop-12@example.org id:mid-loop-21@example.org > OUTPUT"
 
 test_done