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 BF2D06DE01D8 for ; Mon, 2 Apr 2018 04:04:21 -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 U9JyCDtcn9h2 for ; Mon, 2 Apr 2018 04:04:20 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 767F06DE00D4 for ; Mon, 2 Apr 2018 04:04:20 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1f2xG4-0006AB-Ub; Mon, 02 Apr 2018 07:04:16 -0400 Received: (nullmailer pid 16466 invoked by uid 1000); Mon, 02 Apr 2018 11:04:15 -0000 From: David Bremner To: David Bremner , =?UTF-8?q?Antoine=20Beaupr=C3=A9?= , notmuch@notmuchmail.org Subject: [PATCH] WIP: test patch for reference loop problem Date: Mon, 2 Apr 2018 08:03:55 -0300 Message-Id: <20180402110355.16419-1-david@tethera.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180320212235.29113-2-david@tethera.net> References: <20180320212235.29113-2-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: Mon, 02 Apr 2018 11:04:21 -0000 --- lib/thread.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index 3561b27f..356d63ce 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -391,10 +391,15 @@ static void _resolve_thread_relationships (notmuch_thread_t *thread) { notmuch_message_node_t *node; - notmuch_message_t *message, *parent; + notmuch_message_t *message, *first_message = NULL, *parent; const char *in_reply_to; - for (node = thread->message_list->head; node; node = node->next) { + node = thread->message_list->head; + if (node) { + first_message = node->message; + node = node->next; + } + for (; 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) && @@ -406,6 +411,19 @@ _resolve_thread_relationships (notmuch_thread_t *thread) _notmuch_message_list_add_message (thread->toplevel_list, message); } + /* XXX: this is probably nonsense: if we didn't find any top level + * messages, choose one at random */ + if (first_message) { + in_reply_to = _notmuch_message_get_in_reply_to (first_message); + if (thread->toplevel_list->head && in_reply_to && strlen (in_reply_to) && + g_hash_table_lookup_extended (thread->message_hash, + in_reply_to, NULL, + (void **) &parent)) + _notmuch_message_add_reply (parent, first_message); + else + _notmuch_message_list_add_message (thread->toplevel_list, first_message); + } + /* XXX: After scanning through the entire list looking for parents * via "In-Reply-To", we should do a second pass that looks at the * list of messages IDs in the "References" header instead. (And -- 2.16.2