--- /dev/null
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id A1CF06DE02A7\r
+ for <notmuch@notmuchmail.org>; Fri, 1 Apr 2016 18:50:21 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id pclIU35IZRz2 for <notmuch@notmuchmail.org>;\r
+ Fri, 1 Apr 2016 18:50:13 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 9A1C36DE0243\r
+ for <notmuch@notmuchmail.org>; Fri, 1 Apr 2016 18:50:13 -0700 (PDT)\r
+Received: from fifthhorseman.net (unknown [190.172.4.74])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 2E2A9F999\r
+ for <notmuch@notmuchmail.org>; Fri, 1 Apr 2016 21:50:09 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id 802DE205D6; Fri, 1 Apr 2016 20:31:55 -0300 (BRT)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 1/2] verify during thread-breakage that messages are removed\r
+ as well\r
+Date: Fri, 1 Apr 2016 20:31:54 -0300\r
+Message-Id: <1459553515-18802-1-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.0.rc3\r
+In-Reply-To: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 02 Apr 2016 01:50:21 -0000\r
+\r
+One risk of fixes to the thread-breakage problem is that we could fail\r
+to remove the search term indexes entirely. These additional subtests\r
+should guard against that.\r
+---\r
+ test/T590-thread-breakage.sh | 17 +++++++++++++++++\r
+ 1 file changed, 17 insertions(+)\r
+\r
+diff --git a/test/T590-thread-breakage.sh b/test/T590-thread-breakage.sh\r
+index 704f504..f3e725c 100755\r
+--- a/test/T590-thread-breakage.sh\r
++++ b/test/T590-thread-breakage.sh\r
+@@ -17,6 +17,7 @@ To: Bob <bob@example.net>\r
+ Date: Thu, 31 Mar 2016 20:10:00 -0400\r
+ \r
+ This is the first message in the thread.\r
++Apple\r
+ EOF\r
+ }\r
+ \r
+@@ -32,10 +33,18 @@ To: Alice <alice@example.net>\r
+ Date: Thu, 31 Mar 2016 20:15:00 -0400\r
+ \r
+ This is the second message in the thread.\r
++Banana\r
+ EOF\r
+ }\r
+ \r
+ \r
++test_subject_count() {\r
++ notmuch new >/dev/null\r
++ test_begin_subtest "${3:-looking for $2 instance of '$1'}"\r
++ count=$(notmuch count --output=threads "$1")\r
++ test_expect_equal "$count" "$2"\r
++}\r
++\r
+ test_thread_count() {\r
+ notmuch new >/dev/null\r
+ test_begin_subtest "${2:-Expecting $1 thread(s)}"\r
+@@ -47,17 +56,25 @@ test_thread_count 0 'There should be no threads initially'\r
+ \r
+ message_a\r
+ test_thread_count 1 'One message in: one thread'\r
++test_subject_count apple 1\r
++test_subject_count banana 0\r
+ \r
+ message_b\r
+ test_thread_count 1 'Second message in the same thread: one thread'\r
++test_subject_count apple 1\r
++test_subject_count banana 1\r
+ \r
+ rm -f ${MAIL_DIR}/cur/a\r
+ test_thread_count 1 'First message removed: still only one thread'\r
++test_subject_count apple 0\r
++test_subject_count banana 1\r
+ \r
+ message_a\r
+ # this is known to fail (it shows 2 threads) because no "ghost\r
+ # message" was created for message A when it was removed from the\r
+ # index, despite message B still pointing to it.\r
+ test_thread_count 1 'First message reappears: should return to the same thread'\r
++test_subject_count apple 1\r
++test_subject_count banana 1\r
+ \r
+ test_done\r
+-- \r
+2.8.0.rc3\r
+\r