--- /dev/null
+Return-Path: <prvs=350ea838c=jrosenthal@jhu.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 ECA27431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Oct 2014 09:49:03 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.026\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.026 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3, RDNS_NONE=1.274] 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 vAh0fxHEIS8B for <notmuch@notmuchmail.org>;\r
+ Tue, 7 Oct 2014 09:48:55 -0700 (PDT)\r
+Received: from smtpauth.johnshopkins.edu (unknown [162.129.8.150])\r
+ (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 27EDF431FAF\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Oct 2014 09:48:55 -0700 (PDT)\r
+X-IronPort-AV: E=Sophos;i="5.04,671,1406606400"; d="scan'208";a="99715741"\r
+Received: from guppy.hwcampus.jhu.edu (HELO localhost) ([10.161.32.234])\r
+ by ipex0.johnshopkins.edu with ESMTP/TLS/AES128-SHA;\r
+ 07 Oct 2014 12:48:53 -0400\r
+From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] Avoid empty thread names if possible.\r
+Date: Tue, 7 Oct 2014 12:35:44 -0400\r
+Message-ID: <87oatnakqy.fsf@jhu.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Tue, 07 Oct 2014 16:49:04 -0000\r
+\r
+Currently the thread is named based on either the oldest or newest\r
+matching message (depending on the search order). If this message has\r
+an empty subject, though, the thread will show up with an empty\r
+subject in the search results. (See the thread starting with\r
+`id:1412371140-21051-1-git-send-email-david@tethera.net` for an\r
+example.)\r
+\r
+This patch changes the behavior to name based on the oldest/newest\r
+matching non-empty subject. This is particularly helpful for patchsets.\r
+If the only subjects are empty, the thread subject will still be empty.\r
+\r
+Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+---\r
+ lib/thread.cc | 6 ++++--\r
+ 1 file changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 8922403..ea10295 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -348,18 +348,20 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
+ {\r
+ time_t date;\r
+ notmuch_message_t *hashed_message;\r
++ const char *cur_subject;\r
+ \r
+ date = notmuch_message_get_date (message);\r
++ cur_subject = notmuch_thread_get_subject (thread);\r
+ \r
+ if (date < thread->oldest || ! thread->matched_messages) {\r
+ thread->oldest = date;\r
+- if (sort == NOTMUCH_SORT_OLDEST_FIRST)\r
++ if (sort == NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0)\r
+ _thread_set_subject_from_message (thread, message);\r
+ }\r
+ \r
+ if (date > thread->newest || ! thread->matched_messages) {\r
+ thread->newest = date;\r
+- if (sort != NOTMUCH_SORT_OLDEST_FIRST)\r
++ if (sort != NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0)\r
+ _thread_set_subject_from_message (thread, message);\r
+ }\r
+ \r
+-- \r
+2.1.2\r
+\r