--- /dev/null
+Return-Path: <aaronecay@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 37BBC431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Mar 2013 15:56:05 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id V1DnH4WHTqq1 for <notmuch@notmuchmail.org>;\r
+ Sun, 3 Mar 2013 15:56:01 -0800 (PST)\r
+Received: from mail-qe0-f43.google.com (mail-qe0-f43.google.com\r
+ [209.85.128.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 95EFB431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Mar 2013 15:56:01 -0800 (PST)\r
+Received: by mail-qe0-f43.google.com with SMTP id 1so3362385qee.16\r
+ for <notmuch@notmuchmail.org>; Sun, 03 Mar 2013 15:56:01 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=x-received:from:to:cc:subject:in-reply-to:references:user-agent\r
+ :date:message-id:mime-version:content-type;\r
+ bh=35z6Zyv+gYqaZZOgfJ0ZKm7sQt0qSjkJLHQIq+Sw1po=;\r
+ b=BLlyMlDCOvZww549uMory2/3a8Re1qe8fq06U7U/4EpMrbZJJcCVZFgqw/aU/PZENj\r
+ cR8y/MTb7hrKcNiHsiBmyM4iN1I9EcIq3JQyrQWSbE9XmBYHCnauh1jYwZmW9Ao8GR4o\r
+ AxfKUKU0Z37RfCJtsrQ3VYhIQbc745fV4pkuSQQDWLvNbSnNQeUQL3cQ1sWvFVX5Ysgo\r
+ 1UuUJECs2AQpUymxB4ITzBuo1zLZtVMkxgJoQ2XOPAvDHaTc0dviwxnZvYbqWUeUHNye\r
+ izoZPRY1vAS2DivKhcYOXhtUSkc2/qecwDptftaQFRf0xJDzxOi6h32LrkQC0oiRJ4cP\r
+ rZBA==\r
+X-Received: by 10.229.196.138 with SMTP id eg10mr6324192qcb.93.1362354961024; \r
+ Sun, 03 Mar 2013 15:56:01 -0800 (PST)\r
+Received: from localhost (c-68-80-94-73.hsd1.pa.comcast.net. [68.80.94.73])\r
+ by mx.google.com with ESMTPS id m6sm3499808qed.7.2013.03.03.15.55.59\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 03 Mar 2013 15:56:00 -0800 (PST)\r
+From: Aaron Ecay <aaronecay@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [RFC] [PATCH] lib/database.cc: change how the parent of a message\r
+ is calculated\r
+In-Reply-To: <87wqtovygl.fsf@gmail.com>\r
+References: <1361836225-17279-1-git-send-email-aaronecay@gmail.com>\r
+ <87621cteeb.fsf@nikula.org> <871ubzt5gr.fsf@nikula.org>\r
+ <87wqtovygl.fsf@gmail.com>\r
+User-Agent: Notmuch/0.15.2+33~g0c0a530 (http://notmuchmail.org)\r
+ Emacs/24.3.50.2 (x86_64-unknown-linux-gnu)\r
+Date: Sun, 03 Mar 2013 18:55:58 -0500\r
+Message-ID: <87sj4cvy0h.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; boundary="=-=-="\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 03 Mar 2013 23:56:05 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+git send-email is mad about lines >998 characters in the test patch, so\r
+I=E2=80=99m sending the patches as attachments to this email. (Is there a\r
+better way to include the expected output of a notmuch command which\r
+outputs long lines in a test script?)\r
+\r
+\r
+--=-=-=\r
+Content-Type: text/x-patch\r
+Content-Disposition: inline;\r
+ filename=0001-test-add-tests-for-the-handling-of-References-and-In.patch\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+>From 23836241dd304b98f2a05803fbb5a5a94f563050 Mon Sep 17 00:00:00 2001\r
+From: Aaron Ecay <aaronecay@gmail.com>\r
+Date: Sun, 3 Mar 2013 18:14:07 -0500\r
+Subject: [PATCH 1/2] test: add tests for the handling of References and\r
+ In-Reply-To headers\r
+\r
+These tests are known_broken, the following commit fixes them.\r
+---\r
+ test/thread-replies | 55 +++++++++++++++++++++++++++++++++++++++++++++++++=\r
+++++\r
+ 1 file changed, 55 insertions(+)\r
+ create mode 100755 test/thread-replies\r
+\r
+diff --git a/test/thread-replies b/test/thread-replies\r
+new file mode 100755\r
+index 0000000..fd11a09\r
+--- /dev/null\r
++++ b/test/thread-replies\r
+@@ -0,0 +1,55 @@\r
++#!/usr/bin/env bash\r
++#\r
++# Copyright (c) 2013 Aaron Ecay\r
++#\r
++\r
++test_description=3D'test of proper handling of in-reply-to and references =\r
+headers\r
++\r
++This test makes sure that the thread structure in the notmuch database is\r
++constructed properly, even in the presence of non-RFC-compliant headers'\r
++\r
++. ./test-lib.sh\r
++\r
++test_begin_subtest "Use References when In-Reply-To is broken"\r
++test_subtest_known_broken\r
++add_message '[id]=3D"foo@one.com"' \\r
++ '[subject]=3Done'\r
++add_message '[in-reply-to]=3D"mumble"' \\r
++ '[references]=3D"<foo@one.com>"' \\r
++ '[subject]=3D"Re: one"'\r
++output=3D$(notmuch show --format=3Djson 'subject:one')\r
++test_expect_equal "$output" '[[[{"id": "foo@one.com", "match": true, "excl=\r
+uded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/src/=\r
+notmuch/test/tmp.thread-replies/mail/msg-001", "timestamp": 978709437, "dat=\r
+e_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subjec=\r
+t": "one", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To":=\r
+ "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Jan 20=\r
+01 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "cont=\r
+ent": "This is just a test message (#1)\n"}]}, [[{"id": "msg-002@notmuch-te=\r
+st-suite", "match": true, "excluded": false, "filename": "/home/aecay/devel=\r
+opment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-002=\r
+", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox",=\r
+ "unread"], "headers": {"Subject": "Re: one", "From": "Notmuch Test Suite <=\r
+test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuch=\r
+mail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, =\r
+"content-type": "text/plain", "content": "This is just a test message (#2)\=\r
+n"}]}, []]]]]]'\r
++\r
++test_begin_subtest "Prefer References to In-Reply-To"\r
++test_subtest_known_broken\r
++add_message '[id]=3D"foo@two.com"' \\r
++ '[subject]=3Dtwo'\r
++add_message '[in-reply-to]=3D"<bar@baz.com>"' \\r
++ '[references]=3D"<foo@two.com>"' \\r
++ '[subject]=3D"Re: two"'\r
++output=3D$(notmuch show --format=3Djson 'subject:two')\r
++test_expect_equal "$output" '[[[{"id": "foo@two.com", "match": true, "excl=\r
+uded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/src/=\r
+notmuch/test/tmp.thread-replies/mail/msg-003", "timestamp": 978709437, "dat=\r
+e_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subjec=\r
+t": "two", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To":=\r
+ "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Jan 20=\r
+01 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "cont=\r
+ent": "This is just a test message (#3)\n"}]}, [[{"id": "msg-004@notmuch-te=\r
+st-suite", "match": true, "excluded": false, "filename": "/home/aecay/devel=\r
+opment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-004=\r
+", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox",=\r
+ "unread"], "headers": {"Subject": "Re: two", "From": "Notmuch Test Suite <=\r
+test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuch=\r
+mail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, =\r
+"content-type": "text/plain", "content": "This is just a test message (#4)\=\r
+n"}]}, []]]]]]'\r
++\r
++test_begin_subtest "Use In-Reply-To when no References"\r
++test_subtest_known_broken\r
++add_message '[id]=3D"foo@three.com"' \\r
++ '[subject]=3D"three"'\r
++add_message '[in-reply-to]=3D"<foo@three.com>"' \\r
++ '[subject]=3D"Re: three"'\r
++output=3D$(notmuch show --format=3Djson 'subject:three')\r
++test_expect_equal "$output" '[[[{"id": "foo@three.com", "match": true, "ex=\r
+cluded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/sr=\r
+c/notmuch/test/tmp.thread-replies/mail/msg-005", "timestamp": 978709437, "d=\r
+ate_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subj=\r
+ect": "three", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "=\r
+To": "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Ja=\r
+n 2001 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "=\r
+content": "This is just a test message (#5)\n"}]}, [[{"id": "msg-006@notmuc=\r
+h-test-suite", "match": true, "excluded": false, "filename": "/home/aecay/d=\r
+evelopment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg=\r
+-006", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inb=\r
+ox", "unread"], "headers": {"Subject": "Re: three", "From": "Notmuch Test S=\r
+uite <test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@n=\r
+otmuchmail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id=\r
+": 1, "content-type": "text/plain", "content": "This is just a test message=\r
+ (#6)\n"}]}, []]]]]]'\r
++\r
++test_begin_subtest "Use last Reference"\r
++test_subtest_known_broken\r
++add_message '[id]=3D"foo@four.com"' \\r
++ '[subject]=3D"four"'\r
++add_message '[id]=3D"bar@four.com"' \\r
++ '[subject]=3D"not-four"'\r
++add_message '[in-reply-to]=3D"<baz@four.com>"' \\r
++ '[references]=3D"<baz@four.com> <foo@four.com>"' \\r
++ '[subject]=3D"neither"'\r
++output=3D$(notmuch show --format=3Djson 'subject:four')\r
++test_expect_equal "$output" '[[[{"id": "foo@four.com", "match": true, "exc=\r
+luded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/src=\r
+/notmuch/test/tmp.thread-replies/mail/msg-007", "timestamp": 978709437, "da=\r
+te_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subje=\r
+ct": "four", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To=\r
+": "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Jan =\r
+2001 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "co=\r
+ntent": "This is just a test message (#7)\n"}]}, [[{"id": "msg-009@notmuch-=\r
+test-suite", "match": false, "excluded": false, "filename": "/home/aecay/de=\r
+velopment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-=\r
+009", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbo=\r
+x", "unread"], "headers": {"Subject": "neither", "From": "Notmuch Test Suit=\r
+e <test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notm=\r
+uchmail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": =\r
+1, "content-type": "text/plain", "content": "This is just a test message (#=\r
+9)\n"}]}, []]]]], [[{"id": "bar@four.com", "match": true, "excluded": false=\r
+, "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test=\r
+/tmp.thread-replies/mail/msg-008", "timestamp": 978709437, "date_relative":=\r
+ "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subject": "not-fou=\r
+r", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "Notmu=\r
+ch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Jan 2001 15:4=\r
+3:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "=\r
+This is just a test message (#8)\n"}]}, []]]]'\r
++\r
++\r
++test_done\r
+--=20\r
+1.8.1.5\r
+\r
+\r
+--=-=-=\r
+Content-Type: text/x-patch\r
+Content-Disposition: inline;\r
+ filename=0002-lib-database.cc-change-how-the-parent-of-a-message-i.patch\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+>From 57739b9722a86ba50ef97ad7d5d21b3e5bc1a977 Mon Sep 17 00:00:00 2001\r
+From: Aaron Ecay <aaronecay@gmail.com>\r
+Date: Mon, 25 Feb 2013 18:46:41 -0500\r
+Subject: [PATCH 2/2] lib/database.cc: change how the parent of a message is\r
+ calculated\r
+\r
+Presently, the code which finds the parent of a message as it is being\r
+added to the database assumes that the first Message-ID-like substring\r
+of the In-Reply-To header is the parent Message ID. Some mail clients,\r
+however, put stuff other than the Message-ID of the parent in the\r
+In-Reply-To header, such as the email address of the sender of the\r
+parent. This can fool notmuch.\r
+\r
+The updated algorithm prefers the last Message ID in the References\r
+header. The References header lists messages oldest-first, so the last\r
+Message ID is the parent (RFC2822, p. 24). The References header is\r
+also less likely to be in a non-standard\r
+syntax (http://cr.yp.to/immhf/thread.html,\r
+http://www.jwz.org/doc/threading.html). In case the References header\r
+is not to be found, fall back to the old behavior.\r
+\r
+V2 of this patch, incorporating feedback from Jani and (indirectly)\r
+Austin.\r
+---\r
+ lib/database.cc | 48 +++++++++++++++++++++++++++++++++---------------\r
+ test/thread-replies | 4 ----\r
+ 2 files changed, 33 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 91d4329..52ed618 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -501,8 +501,10 @@ _parse_message_id (void *ctx, const char *message_id, =\r
+const char **next)\r
+ * 'message_id' in the result (to avoid mass confusion when a single\r
+ * message references itself cyclically---and yes, mail messages are\r
+ * not infrequent in the wild that do this---don't ask me why).\r
+-*/\r
+-static void\r
++ *\r
++ * Return the last reference parsed, if it is not equal to message_id.\r
++ */\r
++static char *\r
+ parse_references (void *ctx,\r
+ const char *message_id,\r
+ GHashTable *hash,\r
+@@ -511,7 +513,7 @@ parse_references (void *ctx,\r
+ char *ref;\r
+=20\r
+ if (refs =3D=3D NULL || *refs =3D=3D '\0')\r
+- return;\r
++ return NULL;\r
+=20\r
+ while (*refs) {\r
+ ref =3D _parse_message_id (ctx, refs, &refs);\r
+@@ -519,6 +521,17 @@ parse_references (void *ctx,\r
+ if (ref && strcmp (ref, message_id))\r
+ g_hash_table_insert (hash, ref, NULL);\r
+ }\r
++\r
++ /* The return value of this function is used to add a parent\r
++ * reference to the database. We should avoid making a message\r
++ * its own parent, thus the following check.\r
++ */\r
++\r
++ if (ref && strcmp(ref, message_id)) {\r
++ return ref;\r
++ } else {\r
++ return NULL;\r
++ }\r
+ }\r
+=20\r
+ notmuch_status_t\r
+@@ -1510,28 +1523,33 @@ _notmuch_database_link_message_to_parents (notmuch_=\r
+database_t *notmuch,\r
+ {\r
+ GHashTable *parents =3D NULL;\r
+ const char *refs, *in_reply_to, *in_reply_to_message_id;\r
++ const char *last_ref_message_id, *this_message_id;\r
+ GList *l, *keys =3D NULL;\r
+ notmuch_status_t ret =3D NOTMUCH_STATUS_SUCCESS;\r
+=20\r
+ parents =3D g_hash_table_new_full (g_str_hash, g_str_equal,\r
+ _my_talloc_free_for_g_hash, NULL);\r
++ this_message_id =3D notmuch_message_get_message_id (message);\r
+=20\r
+ refs =3D notmuch_message_file_get_header (message_file, "references");\r
+- parse_references (message, notmuch_message_get_message_id (message),\r
+- parents, refs);\r
++ last_ref_message_id =3D parse_references (message,\r
++ this_message_id,\r
++ parents, refs);\r
+=20\r
+ in_reply_to =3D notmuch_message_file_get_header (message_file, "in-rep=\r
+ly-to");\r
+- parse_references (message, notmuch_message_get_message_id (message),\r
+- parents, in_reply_to);\r
+-\r
+- /* Carefully avoid adding any self-referential in-reply-to term. */\r
+- in_reply_to_message_id =3D _parse_message_id (message, in_reply_to, NU=\r
+LL);\r
+- if (in_reply_to_message_id &&\r
+- strcmp (in_reply_to_message_id,\r
+- notmuch_message_get_message_id (message)))\r
+- {\r
++ in_reply_to_message_id =3D parse_references (message,\r
++ this_message_id,\r
++ parents, in_reply_to);\r
++\r
++ /* For the parent of this message, use the last message ID of the\r
++ * References header, if available. If not, fall back to the\r
++ * first message ID in the In-Reply-To header. */\r
++ if (last_ref_message_id) {\r
++ _notmuch_message_add_term (message, "replyto",\r
++ last_ref_message_id);\r
++ } else if (in_reply_to_message_id) {\r
+ _notmuch_message_add_term (message, "replyto",\r
+- _parse_message_id (message, in_reply_to, NULL));\r
++ in_reply_to_message_id);\r
+ }\r
+=20\r
+ keys =3D g_hash_table_get_keys (parents);\r
+diff --git a/test/thread-replies b/test/thread-replies\r
+index fd11a09..6dc6143 100755\r
+--- a/test/thread-replies\r
++++ b/test/thread-replies\r
+@@ -11,7 +11,6 @@ constructed properly, even in the presence of non-RFC-com=\r
+pliant headers'\r
+ . ./test-lib.sh\r
+=20\r
+ test_begin_subtest "Use References when In-Reply-To is broken"\r
+-test_subtest_known_broken\r
+ add_message '[id]=3D"foo@one.com"' \\r
+ '[subject]=3Done'\r
+ add_message '[in-reply-to]=3D"mumble"' \\r
+@@ -21,7 +20,6 @@ output=3D$(notmuch show --format=3Djson 'subject:one')\r
+ test_expect_equal "$output" '[[[{"id": "foo@one.com", "match": true, "excl=\r
+uded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/src/=\r
+notmuch/test/tmp.thread-replies/mail/msg-001", "timestamp": 978709437, "dat=\r
+e_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subjec=\r
+t": "one", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To":=\r
+ "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Jan 20=\r
+01 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "cont=\r
+ent": "This is just a test message (#1)\n"}]}, [[{"id": "msg-002@notmuch-te=\r
+st-suite", "match": true, "excluded": false, "filename": "/home/aecay/devel=\r
+opment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-002=\r
+", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox",=\r
+ "unread"], "headers": {"Subject": "Re: one", "From": "Notmuch Test Suite <=\r
+test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuch=\r
+mail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, =\r
+"content-type": "text/plain", "content": "This is just a test message (#2)\=\r
+n"}]}, []]]]]]'\r
+=20\r
+ test_begin_subtest "Prefer References to In-Reply-To"\r
+-test_subtest_known_broken\r
+ add_message '[id]=3D"foo@two.com"' \\r
+ '[subject]=3Dtwo'\r
+ add_message '[in-reply-to]=3D"<bar@baz.com>"' \\r
+@@ -31,7 +29,6 @@ output=3D$(notmuch show --format=3Djson 'subject:two')\r
+ test_expect_equal "$output" '[[[{"id": "foo@two.com", "match": true, "excl=\r
+uded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/src/=\r
+notmuch/test/tmp.thread-replies/mail/msg-003", "timestamp": 978709437, "dat=\r
+e_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subjec=\r
+t": "two", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To":=\r
+ "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Jan 20=\r
+01 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "cont=\r
+ent": "This is just a test message (#3)\n"}]}, [[{"id": "msg-004@notmuch-te=\r
+st-suite", "match": true, "excluded": false, "filename": "/home/aecay/devel=\r
+opment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-004=\r
+", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox",=\r
+ "unread"], "headers": {"Subject": "Re: two", "From": "Notmuch Test Suite <=\r
+test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuch=\r
+mail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, =\r
+"content-type": "text/plain", "content": "This is just a test message (#4)\=\r
+n"}]}, []]]]]]'\r
+=20\r
+ test_begin_subtest "Use In-Reply-To when no References"\r
+-test_subtest_known_broken\r
+ add_message '[id]=3D"foo@three.com"' \\r
+ '[subject]=3D"three"'\r
+ add_message '[in-reply-to]=3D"<foo@three.com>"' \\r
+@@ -40,7 +37,6 @@ output=3D$(notmuch show --format=3Djson 'subject:three')\r
+ test_expect_equal "$output" '[[[{"id": "foo@three.com", "match": true, "ex=\r
+cluded": false, "filename": "/home/aecay/development/notmuch/notmuch-git/sr=\r
+c/notmuch/test/tmp.thread-replies/mail/msg-005", "timestamp": 978709437, "d=\r
+ate_relative": "2001-01-05", "tags": ["inbox", "unread"], "headers": {"Subj=\r
+ect": "three", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "=\r
+To": "Notmuch Test Suite <test_suite@notmuchmail.org>", "Date": "Fri, 05 Ja=\r
+n 2001 15:43:57 +0000"}, "body": [{"id": 1, "content-type": "text/plain", "=\r
+content": "This is just a test message (#5)\n"}]}, [[{"id": "msg-006@notmuc=\r
+h-test-suite", "match": true, "excluded": false, "filename": "/home/aecay/d=\r
+evelopment/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg=\r
+-006", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inb=\r
+ox", "unread"], "headers": {"Subject": "Re: three", "From": "Notmuch Test S=\r
+uite <test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@n=\r
+otmuchmail.org>", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id=\r
+": 1, "content-type": "text/plain", "content": "This is just a test message=\r
+ (#6)\n"}]}, []]]]]]'\r
+=20\r
+ test_begin_subtest "Use last Reference"\r
+-test_subtest_known_broken\r
+ add_message '[id]=3D"foo@four.com"' \\r
+ '[subject]=3D"four"'\r
+ add_message '[id]=3D"bar@four.com"' \\r
+--=20\r
+1.8.1.5\r
+\r
+\r
+--=-=-=\r
+Content-Type: text/plain\r
+\r
+\r
+\r
+-- \r
+Aaron Ecay\r
+\r
+--=-=-=--\r