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 4A1826DE0202 for ; Sun, 15 Apr 2018 08:31:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 1.103 X-Spam-Level: * X-Spam-Status: No, score=1.103 tagged_above=-999 required=5 tests=[DATE_IN_PAST_06_12=1.103, RCVD_IN_DNSWL_NONE=-0.0001] 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 nIer9bmbgjfJ for ; Sun, 15 Apr 2018 08:31:51 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id D3DAC6DE0119 for ; Sun, 15 Apr 2018 08:31:50 -0700 (PDT) Received: from fifthhorseman.net (157-131-168-84.fiber.dynamic.sonic.net [157.131.168.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id C4919F99E; Sun, 15 Apr 2018 11:31:47 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id A49F520715; Sun, 15 Apr 2018 03:38:43 -0400 (EDT) From: Daniel Kahn Gillmor To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 3/5] lib: break reference loop by choosing arbitrary top level msg In-Reply-To: <20180414014610.15438-4-david@tethera.net> References: <20180414014610.15438-1-david@tethera.net> <20180414014610.15438-4-david@tethera.net> Date: Sun, 15 Apr 2018 00:38:43 -0700 Message-ID: <87d0z0syv0.fsf@fifthhorseman.net> MIME-Version: 1.0 Content-Type: text/plain 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: Sun, 15 Apr 2018 15:31:53 -0000 On Fri 2018-04-13 22:46:08 -0300, David Bremner wrote: > 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 > + */ Just how arbitrary should we be? Do we want it to be non-deterministic? If we care about determinism, i'd recommend selecting the message with the earliest date as the top-level message, and if multiple messages have the same date, we should sort by Message-ID. --dkg