--- /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 3FDF3429E50\r
+ for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 08:35:58 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 MhjqGQwZ1-kE for <notmuch@notmuchmail.org>;\r
+ Fri, 16 Aug 2013 08:35:54 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+ [18.7.68.35])\r
+ by olra.theworths.org (Postfix) with ESMTP id B66A0429E3A\r
+ for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 08:35:49 -0700 (PDT)\r
+X-AuditID: 12074423-b7f168e00000095a-45-520e46d4b3a5\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 5F.C2.02394.4D64E025; Fri, 16 Aug 2013 11:35:49 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r7GFZkoa021710; \r
+ Fri, 16 Aug 2013 11:35:46 -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 r7GFZi2J020146\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Fri, 16 Aug 2013 11:35:45 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1VAM40-0002va-8E; Fri, 16 Aug 2013 11:35:44 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 2/3] reply: Remove extraneous space from generated\r
+ References\r
+Date: Fri, 16 Aug 2013 11:35:42 -0400\r
+Message-Id: <1376667343-10863-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1376667343-10863-1-git-send-email-amdragon@mit.edu>\r
+References: <1376667343-10863-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFrrEIsWRmVeSWpSXmKPExsUixCmqrHvVjS/IYN5uZos9+7wsrt+cyWzx\r
+ ZuU8Vgdmj7unuTwOf13I4vFs1S3mAOYoLpuU1JzMstQifbsEroxpRzazFPQLV3SvOsXewLic\r
+ v4uRk0NCwERi2a3VjBC2mMSFe+vZuhi5OIQE9jFKXL/xhAXC2cgoserIR3YI5w6TxPwdG5kh\r
+ nLmMEvunbWAB6WcT0JDYtn852CwRAWmJnXdns4LYzALxEm0vtrOD2MICARIHNr0Gq2ERUJWY\r
+ cLgJzOYVcJCYueEcM8QdihLdzyawgdicAo4Sn/s/gc0XAqrZMW8p2wRG/gWMDKsYZVNyq3Rz\r
+ EzNzilOTdYuTE/PyUot0zfRyM0v0UlNKNzGCgovdRXkH45+DSocYBTgYlXh4GSbyBgmxJpYV\r
+ V+YeYpTkYFIS5Z3nyBckxJeUn1KZkVicEV9UmpNafIhRgoNZSYR3qwFQjjclsbIqtSgfJiXN\r
+ waIkzvvs6dlAIYH0xJLU7NTUgtQimKwMB4eSBO9CV6BGwaLU9NSKtMycEoQ0EwcnyHAeoOF7\r
+ QGp4iwsSc4sz0yHypxh1OS4cXviJUYglLz8vVUqc1xmkSACkKKM0D24OLCm8YhQHekuY9xRI\r
+ FQ8wocBNegW0hAloyaQzvCBLShIRUlINjKY3pRok1hs0eyptu76Cc8KUBMa6fwkFSgWSXTF+\r
+ zGbnub5vbF57L3rbk316Z01qlf7764oLbdN//7L/5Oz2+imnHPdOiNuW+Yp31uneiJDLG3tt\r
+ 6hkEtaKnXvnFK6j7W0T6rNmJyQb189k4/r+Ov5IZclfYNWChz/1XVn6Tq/n0DkyeOHfWSiWW\r
+ 4oxEQy3mouJEAE37aCDlAgAA\r
+Cc: tomi.ollila@iki.fi\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, 16 Aug 2013 15:35:58 -0000\r
+\r
+Previously, the References header code seemed to assume\r
+notmuch_message_get_header would return NULL if the header was not\r
+present, but it actually returns "". As a result of this, it was\r
+inserting an unnecessary space when concatenating an empty or missing\r
+original references header with the new reference.\r
+\r
+This shows up in only two tests because the text reply format later\r
+passes the whole reply template through g_mime_filter_headers, which\r
+has the side effect of stripping out this extra space.\r
+---\r
+ notmuch-reply.c | 7 +++++--\r
+ test/multipart | 2 +-\r
+ test/reply | 2 +-\r
+ 3 files changed, 7 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 3b2b58d..472a002 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -537,9 +537,12 @@ create_reply_message(void *ctx,\r
+ "In-Reply-To", in_reply_to);\r
+ \r
+ orig_references = notmuch_message_get_header (message, "references");\r
++ if (!orig_references)\r
++ /* Treat errors like missing References headers. */\r
++ orig_references = "";\r
+ references = talloc_asprintf (ctx, "%s%s%s",\r
+- orig_references ? orig_references : "",\r
+- orig_references ? " " : "",\r
++ *orig_references ? orig_references : "",\r
++ *orig_references ? " " : "",\r
+ in_reply_to);\r
+ g_mime_object_set_header (GMIME_OBJECT (reply),\r
+ "References", references);\r
+diff --git a/test/multipart b/test/multipart\r
+index c974226..2033023 100755\r
+--- a/test/multipart\r
++++ b/test/multipart\r
+@@ -599,7 +599,7 @@ cat <<EOF >EXPECTED\r
+ "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+ "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",\r
+ "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",\r
+- "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},\r
++ "References": "<87liy5ap00.fsf@yoom.home.cworth.org>"},\r
+ "original": {"id": "XXXXX",\r
+ "match": false,\r
+ "excluded": false,\r
+diff --git a/test/reply b/test/reply\r
+index c877ffe..a85ebe5 100755\r
+--- a/test/reply\r
++++ b/test/reply\r
+@@ -242,7 +242,7 @@ test_expect_equal_json "$output" '\r
+ "reply-headers": {\r
+ "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+ "In-reply-to": "<'${gen_msg_id}'>",\r
+- "References": " <'${gen_msg_id}'>",\r
++ "References": "<'${gen_msg_id}'>",\r
+ "Subject": "Re: \u00e0\u00df\u00e7",\r
+ "To": "\u2603 <snowman@example.com>"\r
+ }\r
+-- \r
+1.7.10.4\r
+\r