From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id BBD046DE024E for ; Fri, 13 Apr 2018 18:46:32 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TRK5X1A1DGZs for ; Fri, 13 Apr 2018 18:46:32 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id DDF6A6DE0219 for ; Fri, 13 Apr 2018 18:46:24 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1f7AGm-0008JR-4C; Fri, 13 Apr 2018 21:46:24 -0400 Received: (nullmailer pid 15509 invoked by uid 1000); Sat, 14 Apr 2018 01:46:17 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 3/5] lib: break reference loop by choosing arbitrary top level msg Date: Fri, 13 Apr 2018 22:46:08 -0300 Message-Id: <20180414014610.15438-4-david@tethera.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180414014610.15438-1-david@tethera.net> References: <20180414014610.15438-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Apr 2018 01:46:32 -0000 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 | 8 +++++++- test/T050-new.sh | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index 3561b27f..dbac002f 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -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)) diff --git a/test/T050-new.sh b/test/T050-new.sh index c55a2d97..222c341e 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -356,7 +356,6 @@ test_expect_equal_file EXPECTED OUTPUT add_email_corpus broken test_begin_subtest "reference loop" -test_subtest_known_broken test_expect_code 0 "notmuch show --format=json id:9379QM5Z39_5aa86b134fcfb_174033fc97a2cb98c7198d_sprut@zendesk.com > OUTPUT" test_done -- 2.17.0