--- /dev/null
+Return-Path: <aclements@csail.mit.edu>\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 1DCF0431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 21 Oct 2014 18:51:09 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] 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 hdepnvN9TTz6 for <notmuch@notmuchmail.org>;\r
+ Tue, 21 Oct 2014 18:51:01 -0700 (PDT)\r
+Received: from outgoing.csail.mit.edu (outgoing.csail.mit.edu [128.30.2.149])\r
+ by olra.theworths.org (Postfix) with ESMTP id A9137431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 21 Oct 2014 18:51:01 -0700 (PDT)\r
+Received: from [104.131.20.129] (helo=awakeningjr)\r
+ by outgoing.csail.mit.edu with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16)\r
+ (Exim 4.72) (envelope-from <aclements@csail.mit.edu>)\r
+ id 1Xgl4n-0005IZ-A2; Tue, 21 Oct 2014 21:51:01 -0400\r
+Received: from amthrax by awakeningjr with local (Exim 4.84)\r
+ (envelope-from <aclements@csail.mit.edu>)\r
+ id 1Xgl4n-0000IQ-1j; Tue, 21 Oct 2014 21:51:01 -0400\r
+Date: Tue, 21 Oct 2014 21:51:01 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH v2 12/12] lib: Remove unnecessary thread linking steps\r
+ when using ghost messages\r
+Message-ID: <20141022015101.GF7970@csail.mit.edu>\r
+References: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu>\r
+ <1412637438-4821-13-git-send-email-aclements@csail.mit.edu>\r
+ <87wq7thv27.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <87wq7thv27.fsf@qmul.ac.uk>\r
+User-Agent: Mutt/1.5.23 (2014-03-12)\r
+Cc: notmuch@notmuchmail.org\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: Wed, 22 Oct 2014 01:51:09 -0000\r
+\r
+Quoth Mark Walters on Oct 22 at 12:17 am:\r
+> On Tue, 07 Oct 2014, Austin Clements <aclements@csail.mit.edu> wrote:\r
+> > From: Austin Clements <amdragon@mit.edu>\r
+> >\r
+> > Previously, it was necessary to link new messages to children to work\r
+> > around some (though not all) problems with the old metadata-based\r
+> > approach to stored thread IDs. With ghost messages, this is no longer\r
+> > necessary, so don't bother with child linking when ghost messages are\r
+> > in use.\r
+> > ---\r
+> > lib/database.cc | 21 +++++++++++++++++----\r
+> > 1 file changed, 17 insertions(+), 4 deletions(-)\r
+> >\r
+> > diff --git a/lib/database.cc b/lib/database.cc\r
+> > index 1316529..6e51a72 100644\r
+> > --- a/lib/database.cc\r
+> > +++ b/lib/database.cc\r
+> > @@ -2169,10 +2169,23 @@ _notmuch_database_link_message (notmuch_database_t *notmuch,\r
+> > if (status)\r
+> > goto DONE;\r
+> > \r
+> > - status = _notmuch_database_link_message_to_children (notmuch, message,\r
+> > - &thread_id);\r
+> > - if (status)\r
+> > - goto DONE;\r
+> > + if (! (notmuch->features & NOTMUCH_FEATURE_GHOSTS)) {\r
+> > + /* In general, it shouldn't be necessary to link children,\r
+> > + * since the earlier indexing of those children will have\r
+> > + * stored a thread ID for the missing parent. However, prior\r
+> > + * to ghost messages, these stored thread IDs were NOT\r
+> > + * rewritten during thread merging (and there was no\r
+> > + * performant way to do so), so if indexed children were\r
+> > + * pulled into a different thread ID by a merge, it was\r
+> > + * necessary to pull them *back* into the stored thread ID of\r
+> > + * the parent. With ghost messages, we just rewrite the\r
+> > + * stored thread IDs during merging, so this workaround isn't\r
+> > + * necessary. */\r
+> > + status = _notmuch_database_link_message_to_children (notmuch, message,\r
+> > + &thread_id);\r
+> > + if (status)\r
+> > + goto DONE;\r
+> > + }\r
+> \r
+> Ok so this basically answers my earlier comment. It might be worth\r
+> updating the big comment at the start of the function to match the new\r
+> code though.\r
+\r
+Like so?\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index d063ec8..3601f9d 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -2136,11 +2136,11 @@ _consume_metadata_thread_id (void *ctx, notmuch_database_t *notmuch,\r
+ * reference 'message'.\r
+ *\r
+ * In all cases, we assign to the current message the first thread ID\r
+- * found (through either parent or child). We will also merge any\r
+- * existing, distinct threads where this message belongs to both,\r
+- * (which is not uncommon when messages are processed out of order).\r
++ * found. We will also merge any existing, distinct threads where this\r
++ * message belongs to both, (which is not uncommon when messages are\r
++ * processed out of order).\r
+ *\r
+- * Finally, if no thread ID has been found through parent or child, we\r
++ * Finally, if no thread ID has been found through referenced messages, we\r
+ * call _notmuch_message_generate_thread_id to generate a new thread\r
+ * ID. This should only happen for new, top-level messages, (no\r
+ * References or In-Reply-To header in this message, and no previously\r
+\r
+\r
+> Best wishes\r
+> \r
+> Mark\r
+> \r
+> > \r
+> > /* If not part of any existing thread, generate a new thread ID. */\r
+> > if (thread_id == NULL) {\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r