[PATCH v2 06/14] cli/reply: make references header creation easier to follow
authorJani Nikula <jani@nikula.org>
Sat, 13 Aug 2016 11:37:30 +0000 (14:37 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:25 +0000 (16:22 -0700)
57/7efc3280e340ea6a81c206155a386b48c29d09 [new file with mode: 0644]

diff --git a/57/7efc3280e340ea6a81c206155a386b48c29d09 b/57/7efc3280e340ea6a81c206155a386b48c29d09
new file mode 100644 (file)
index 0000000..e7a35e5
--- /dev/null
@@ -0,0 +1,116 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 2C5556DE3A2C\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:36 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.285\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.285 tagged_above=-999 required=5 tests=[AWL=1.005, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id BkUjg_YYcztH for <notmuch@notmuchmail.org>;\r
+ Sat, 13 Aug 2016 04:39:28 -0700 (PDT)\r
+Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
+ [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id EFDDC6DE3844 for\r
+ <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:12 -0700 (PDT)\r
+Received: by mail-wm0-f68.google.com with SMTP id i138so2004294wmf.3\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:12 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references\r
+ :in-reply-to:references;\r
+ bh=pYUqjKEAM2QcAMxPIpXQWiHvzp0ChQDW96w9W+kxwCw=;\r
+ b=dGZeQFOYayJMokePpdIDtGBMPpFrNjfpUBPZkCoR0ioUlUiE7bQLG1A6gogyPejYr0\r
+ MwnYJEbEW62s+Qu3HXHdQTePyMJVkFQ3BwuXGEfeCu55IZaXURllueMIDO0kNc4j7Rfl\r
+ gkqESI231aDtIcaecGDzANOrG0Q7lOZmz2XLvW2JMTOXVf1Iv4a0Tsy6YRVcnNoIFDKB\r
+ RH8y1eBm8cmhkrpO39Q0Z0wkoFBBWw820GTyXWUdf/qpK2vsXKcilO/M7wYLHYOou/Ep\r
+ +Ekd+OhN7wHheitUiQ47h3aA13k1r1Ld5WYK7ITQ37QlfsRfYviNp8O2KRG09QKHrP6i\r
+ zcNQ==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=pYUqjKEAM2QcAMxPIpXQWiHvzp0ChQDW96w9W+kxwCw=;\r
+ b=ZaLDWmcKzjG379hA/diufLwmEOrfDlMHdddJLniM9FZkeb9lPRereZCFStWS0/N+Hv\r
+ 5DG0MfzRVxl1mbhsiyTPY2yWuaKq/GwHtiiQg4R5j+Gz0wbuL0HiX9FxZU/nCmgboNRb\r
+ K0BzWLFfR5Qz2guQVn+yJdeAxbBnobywDIp5diwPr7EHhfZboOOcvBRFKhustvZH9fSa\r
+ zi9F12YEEg6kZ2+7B2H1HkXiJdJXHvD2BIcgCaIyqzf5WwH3sWtrxFe1tSF75w3Pwm2O\r
+ p/BIDrgjojZNPEQI52ZuQ8GXY+VQLybla/FSOqbSdIKmbz0ZKP3BynjrmRNHw32RNerT\r
+ DpAw==\r
+X-Gm-Message-State:\r
+ AEkoouuEYw4Gn9Tx2+rUIpje8Gbk6p49fojjZ9Ac7sZ9w9DESxDQ9ZUDdQlVQMVs33YRqw==\r
+X-Received: by 10.194.142.78 with SMTP id ru14mr23354803wjb.41.1471088351478; \r
+ Sat, 13 Aug 2016 04:39:11 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c368-70.dhcp.inet.fi.\r
+ [88.195.104.70])\r
+ by smtp.gmail.com with ESMTPSA id ko7sm11711519wjc.48.2016.08.13.04.39.10\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 13 Aug 2016 04:39:10 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Cc: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,\r
+       jani@nikula.org\r
+Subject: [PATCH v2 06/14] cli/reply: make references header creation easier to\r
+ follow\r
+Date: Sat, 13 Aug 2016 14:37:30 +0300\r
+Message-Id:\r
+ <3489bb6606aa6a3fa6d9fc2e9c473c01a7d997eb.1471088022.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1471088022.git.jani@nikula.org>\r
+References: <cover.1471088022.git.jani@nikula.org>\r
+In-Reply-To: <cover.1471088022.git.jani@nikula.org>\r
+References: <cover.1471088022.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 13 Aug 2016 11:39:36 -0000\r
+\r
+Just use strdup when original references is not available, instead of\r
+trying to cram everything into a monster asprintf. There should be no\r
+functional changes.\r
+---\r
+ notmuch-reply.c | 13 ++++++-------\r
+ 1 file changed, 6 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index eb07405591fd..c2d7402d40ae 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -538,13 +538,12 @@ create_reply_message(void *ctx,\r
+     g_mime_object_set_header (GMIME_OBJECT (reply), "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
+-                                in_reply_to);\r
++    if (orig_references && *orig_references)\r
++      references = talloc_asprintf (ctx, "%s %s", orig_references,\r
++                                    in_reply_to);\r
++    else\r
++      references = talloc_strdup (ctx, in_reply_to);\r
++\r
+     g_mime_object_set_header (GMIME_OBJECT (reply), "References", references);\r
\r
+     from_addr = add_recipients_from_message (reply, config,\r
+-- \r
+2.1.4\r
+\r