--- /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 1A727429E2F\r
+ for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 08:15:38 -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 w76czCu95UHV for <notmuch@notmuchmail.org>;\r
+ Fri, 16 Aug 2013 08:15:32 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id BC6D0431E82\r
+ for <notmuch@notmuchmail.org>; Fri, 16 Aug 2013 08:15:32 -0700 (PDT)\r
+X-AuditID: 1209190f-b7fa58e000000953-8a-520e4214b77e\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id C9.14.02387.4124E025; Fri, 16 Aug 2013 11:15:32 -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 r7GFFUiC019207; \r
+ Fri, 16 Aug 2013 11:15:30 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (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 r7GFFRpp012041\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Fri, 16 Aug 2013 11:15:28 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@MIT.EDU>)\r
+ id 1VALkM-0002RV-Gz; Fri, 16 Aug 2013 11:15:26 -0400\r
+Date: Fri, 16 Aug 2013 11:15:25 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jani Nikula <jani@nikula.org>\r
+Subject: Re: [PATCH v2 2/3] reply: Remove extraneous space from generated\r
+ References\r
+Message-ID: <20130816151525.GH13257@mit.edu>\r
+References: <1376587658-19202-1-git-send-email-amdragon@mit.edu>\r
+ <1376587658-19202-3-git-send-email-amdragon@mit.edu>\r
+ <87k3jl3ehe.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <87k3jl3ehe.fsf@nikula.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsUixCmqrCvixBdk8H47h0XTdGeL6zdnMlu8\r
+ WTmP1YHZ4/DXhSwet+6/Zvd4tuoWcwBzFJdNSmpOZllqkb5dAldG1/o1rAWTpCoubJ3P1sA4\r
+ Q6SLkZNDQsBEYv28ThYIW0ziwr31bF2MXBxCAvsYJRonTmQHSQgJbGSUeNBpDpE4zSSx6OIT\r
+ FghnCaPE9h9nmEGqWARUJfruPwTrYBPQkNi2fzkjiC0ioCix+eR+MJtZQF9i5cmZYPXCAmES\r
+ s/fdZQWxeQV0JB41/mWGGDqVUWLao1nMEAlBiZMzn7BANGtJ3Pj3kqmLkQPIlpZY/o8DJMwJ\r
+ tOvPv06w+aICKhJTTm5jm8AoNAtJ9ywk3bMQuhcwMq9ilE3JrdLNTczMKU5N1i1OTszLSy3S\r
+ NdHLzSzRS00p3cQIDnVJ/h2M3w4qHWIU4GBU4uFlmMgbJMSaWFZcmXuIUZKDSUmUd54jX5AQ\r
+ X1J+SmVGYnFGfFFpTmrxIUYJDmYlEd6tBkA53pTEyqrUonyYlDQHi5I477OnZwOFBNITS1Kz\r
+ U1MLUotgsjIcHEoSvOkgQwWLUtNTK9Iyc0oQ0kwcnCDDeYCGN4PU8BYXJOYWZ6ZD5E8x6nJc\r
+ OLzwE6MQS15+XqqUOG85SJEASFFGaR7cHFiKesUoDvSWMG8ISBUPML3BTXoFtIQJaMmkM7wg\r
+ S0oSEVJSDYySCmr5e4+FuQeddX66MrnZetNmrZW6D490Lqhy+BdQGZTcn5Nz9UOmjLThToPG\r
+ 0Mp/9+qP3JW6Vbto8js5hcUqecdL1527eqQzoGLeI58teWfN1GQFE1ed1pSLd42oPp6/eO3k\r
+ uRqX1ziJ3gq4/b2AY1EZx9PsCeWBtsealx4vEa+dLif0M0qJpTgj0VCLuag4EQBnP2vdLAMA AA==\r
+Cc: tomi.ollila@iki.fi, 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: Fri, 16 Aug 2013 15:15:38 -0000\r
+\r
+Quoth Jani Nikula on Aug 16 at 5:19 pm:\r
+> On Thu, 15 Aug 2013, Austin Clements <amdragon@MIT.EDU> wrote:\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 | 14 ++++++++------\r
+> > test/multipart | 2 +-\r
+> > test/reply | 2 +-\r
+> > 3 files changed, 10 insertions(+), 8 deletions(-)\r
+> >\r
+> > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> > index 3b2b58d..0f3b9cd 100644\r
+> > --- a/notmuch-reply.c\r
+> > +++ b/notmuch-reply.c\r
+> > @@ -537,12 +537,14 @@ create_reply_message(void *ctx,\r
+> > "In-Reply-To", in_reply_to);\r
+> > \r
+> > orig_references = notmuch_message_get_header (message, "references");\r
+> > - references = talloc_asprintf (ctx, "%s%s%s",\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
+> > + if (orig_references) {\r
+> > + references = talloc_asprintf (ctx, "%s%s%s",\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
+> > + }\r
+> \r
+> If orig_references turned out to be NULL, wouldn't this then fail to add\r
+> a References: header with in_reply_to in it?\r
+\r
+That's true. It's not clear what the best course of action is if\r
+orig_references is NULL, but you're right that failing to produce a\r
+References header altogether is probably not it. I'll make it treat\r
+errors and missing/empty References headers identically.\r
+\r
+> Jani.\r
+> \r
+> \r
+> > \r
+> > return reply;\r
+> > }\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