[PATCH 3/5] lib: break reference loop by choosing arbitrary top level msg

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sun Apr 15 00:38:43 PDT 2018


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


More information about the notmuch mailing list