[PATCH 5/7] cli/reply: make references header creation easier to follow
authorJani Nikula <jani@nikula.org>
Sat, 18 Jun 2016 21:31:31 +0000 (00:31 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:06 +0000 (16:22 -0700)
c9/353b3886f193f9b7c0391283222095a297d3e8 [new file with mode: 0644]

diff --git a/c9/353b3886f193f9b7c0391283222095a297d3e8 b/c9/353b3886f193f9b7c0391283222095a297d3e8
new file mode 100644 (file)
index 0000000..4d708ee
--- /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 6D3626DE028C\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:26 -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.563\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.563 tagged_above=-999 required=5 tests=[AWL=0.157,\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 NyIsEA5Iqzqt for <notmuch@notmuchmail.org>;\r
+ Sat, 18 Jun 2016 14:33:18 -0700 (PDT)\r
+Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com\r
+ [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id CE26A6DE02D1 for\r
+ <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:06 -0700 (PDT)\r
+Received: by mail-wm0-f67.google.com with SMTP id r201so5510080wme.0\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:06 -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=RasAI0nmLk1MCB9A5xji8+gJRppTliIHrck9AkmpNnfEYnlnxLfE4jnBS49vdR9i8R\r
+ X0CwKqtzZh4FaD1Ver0rdxtHfnSRc4fSi0IGDIBYIJPkSXXxgViIQMrrunXuLtRgYjA2\r
+ vVQiGOWpm+BDScdAE/KGFYARYhMvXjQKxI8btB+IorzHI5GgjacaDlsfT84pNbXLnEU4\r
+ yeK60yOC6a5jPNCflDCZ9YOwBk4fU8in3+/2w9WOPFabFvyOglKPmH6re2pce/MYGF2Y\r
+ ZtrmFii3gzkP8HTOs/522LbO9NbC5twlD+Dd0n4VtdGkxHvCGEx+EtwWVRyhUBbTGBXI\r
+ JBqg==\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=YtPrJgcRry6JnH7ZTEb/0LXbBRdGL9AoRUqJWeTYHN83m/VlAl3wawkDZo840lHdSp\r
+ HkzLwGaLPbNB+BwqfpEZImAVtodo6y3j79CG54xN35dAjLsSqoL16NJ+e5MibFFoCStL\r
+ vGDStW928IaArnj+P+uuysY3Z4tKzQUCPtYWWZbNWzvUt7yxJwTSHMZV8MQ0+Lp+YAlx\r
+ TO7eDNukqdMt5YSbG8573HwVvWibEBFyVBteDjk5mHyLA0/9g5fP/XFfFPUtFDHRpKE7\r
+ PPJ1wPxMtrCWO+eU350CowhnNa8aVzIKNbHQYrShvU/rq4wi3+PllqSvlIsPBwxviFh0\r
+ pkJQ==\r
+X-Gm-Message-State:\r
+ ALyK8tIBmFHNXO3BoxpR6e4HKo8GhBITPhxzEtQISjYRMmZ45n5QKbGHgi03qLOTgq+GvA==\r
+X-Received: by 10.194.237.33 with SMTP id uz1mr7637646wjc.5.1466285585445;\r
+ Sat, 18 Jun 2016 14:33:05 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4e-81.dhcp.inet.fi.\r
+ [188.238.78.81])\r
+ by smtp.gmail.com with ESMTPSA id o10sm18783341wjs.38.2016.06.18.14.33.04\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 18 Jun 2016 14:33:04 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Cc: jani@nikula.org,\r
+       Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+Subject: [PATCH 5/7] cli/reply: make references header creation easier to\r
+ follow\r
+Date: Sun, 19 Jun 2016 00:31:31 +0300\r
+Message-Id:\r
+ <b538845ba9a38be49292fe53d6de21e7000122b3.1466284726.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1466284726.git.jani@nikula.org>\r
+References: <cover.1466284726.git.jani@nikula.org>\r
+In-Reply-To: <cover.1466284726.git.jani@nikula.org>\r
+References: <cover.1466284726.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, 18 Jun 2016 21:33:26 -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