--- /dev/null
+Return-Path: <amdragon@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 E301E429E32\r
+ for <notmuch@notmuchmail.org>; Thu, 31 Jul 2014 19:10:36 -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 sSiOIOZ3A1MD for <notmuch@notmuchmail.org>;\r
+ Thu, 31 Jul 2014 19:10:30 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+ [18.9.25.14])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id D3D5D431FC4\r
+ for <notmuch@notmuchmail.org>; Thu, 31 Jul 2014 19:10:13 -0700 (PDT)\r
+X-AuditID: 1209190e-f79946d000007db1-3b-53daf7036d68\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 73.DF.32177.307FAD35; Thu, 31 Jul 2014 22:10:11 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s712A8eI008857; \r
+ Thu, 31 Jul 2014 22:10:09 -0400\r
+Received: from drake.dyndns.org\r
+ (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [216.15.114.40]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s712A7jO029991\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Thu, 31 Jul 2014 22:10:08 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1XD2II-00033v-71; Thu, 31 Jul 2014 22:10:06 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 11/13] lib: Support empty header values in database\r
+Date: Thu, 31 Jul 2014 22:10:01 -0400\r
+Message-Id: <1406859003-11561-12-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 2.0.0\r
+In-Reply-To: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
+References: <1406859003-11561-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrcv8/VawQetuK4vVc3ksrt+cyezA\r
+ 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdw9+4Sp4LV4xdkFO5kbGNuFuxg5OSQETCRu\r
+ LP3DDmGLSVy4t56ti5GLQ0hgNpPEhJ/NzBDORkaJndefskI4d5gkDl3/wQjhzGWUmLlrDQtI\r
+ P5uAhsS2/csZQWwRAWmJnXdns4LYzAKOEp/3L2IDsYUF3CRa5h8H28cioCpx4co7oHoODl6g\r
+ mi/buSDOkJNouPEJrJwTKPz/3wKwMUICDhKtp7cyT2DkX8DIsIpRNiW3Sjc3MTOnODVZtzg5\r
+ MS8vtUjXWC83s0QvNaV0EyM4kCT5djB+Pah0iFGAg1GJh3dG+K1gIdbEsuLK3EOMkhxMSqK8\r
+ Nh+BQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4X34AyvGmJFZWpRblw6SkOViUxHnfWlsFCwmk\r
+ J5akZqemFqQWwWRlODiUJHjPfAVqFCxKTU+tSMvMKUFIM3FwggznARou9A1keHFBYm5xZjpE\r
+ /hSjopQ47x6QZgGQREZpHlwvLNJfMYoDvSLM+xCkigeYJOC6XwENZgIa/PzWdZDBJYkIKakG\r
+ xph/x5nunzeUicjZXP5pYXrf1L0BMocyf/sv7w45wiHFvHOXfkrDwpLTcf2X2bknZvg3W3x6\r
+ 8DjHtCc0LNxGyXdqpX3n43l/muYEzEly/O/4YPuK1Tvvid9bfMepXFpVwPP2nDftGllr/NIS\r
+ ZDJ9/j1aPX+p89lfj86fKLCuvt951WKVdODSRiWW4oxEQy3mouJEACMJbbjPAgAA\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: Fri, 01 Aug 2014 02:10:37 -0000\r
+\r
+Commit 567bcbc2 introduced support for storing various headers in\r
+document values. However, doing so in a backwards-compatible way\r
+meant that genuinely empty header values could not be distinguished\r
+from the old behavior of not storing the headers at all, so these\r
+required parsing the original message.\r
+\r
+Now that we have database features, new databases can declare that all\r
+messages have header values, so if we have this feature flag, we can\r
+use the stored header value even if it's the empty string.\r
+\r
+This requires slight cleanup to notmuch_message_get_header, since the\r
+code previously couldn't distinguish between empty headers and headers\r
+that are never stored in the database (previously this distinction\r
+didn't matter).\r
+---\r
+ lib/message.cc | 45 +++++++++++++++++++++++++++------------------\r
+ 1 file changed, 27 insertions(+), 18 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index e6a5a5a..4fc427f 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -412,26 +412,35 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)\r
+ const char *\r
+ notmuch_message_get_header (notmuch_message_t *message, const char *header)\r
+ {\r
+- try {\r
+- std::string value;\r
+-\r
+- /* Fetch header from the appropriate xapian value field if\r
+- * available */\r
+- if (strcasecmp (header, "from") == 0)\r
+- value = message->doc.get_value (NOTMUCH_VALUE_FROM);\r
+- else if (strcasecmp (header, "subject") == 0)\r
+- value = message->doc.get_value (NOTMUCH_VALUE_SUBJECT);\r
+- else if (strcasecmp (header, "message-id") == 0)\r
+- value = message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID);\r
+-\r
+- if (!value.empty())\r
++ Xapian::valueno slot = Xapian::BAD_VALUENO;\r
++\r
++ /* Fetch header from the appropriate xapian value field if\r
++ * available */\r
++ if (strcasecmp (header, "from") == 0)\r
++ slot = NOTMUCH_VALUE_FROM;\r
++ else if (strcasecmp (header, "subject") == 0)\r
++ slot = NOTMUCH_VALUE_SUBJECT;\r
++ else if (strcasecmp (header, "message-id") == 0)\r
++ slot = NOTMUCH_VALUE_MESSAGE_ID;\r
++\r
++ if (slot != Xapian::BAD_VALUENO) {\r
++ try {\r
++ std::string value = message->doc.get_value (slot);\r
++\r
++ /* If we have NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES, then\r
++ * empty values indicate empty headers. If we don't, then\r
++ * it could just mean we didn't record the header. */\r
++ if ((message->notmuch->features &\r
++ NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES) ||\r
++ ! value.empty())\r
+ return talloc_strdup (message, value.c_str ());\r
+ \r
+- } catch (Xapian::Error &error) {\r
+- fprintf (stderr, "A Xapian exception occurred when reading header: %s\n",\r
+- error.get_msg().c_str());\r
+- message->notmuch->exception_reported = TRUE;\r
+- return NULL;\r
++ } catch (Xapian::Error &error) {\r
++ fprintf (stderr, "A Xapian exception occurred when reading header: %s\n",\r
++ error.get_msg().c_str());\r
++ message->notmuch->exception_reported = TRUE;\r
++ return NULL;\r
++ }\r
+ }\r
+ \r
+ /* Otherwise fall back to parsing the file */\r
+-- \r
+2.0.0\r
+\r