[PATCH 6/7] cli/reply: reuse create_reply_message() also for headers-only format
authorJani Nikula <jani@nikula.org>
Sat, 18 Jun 2016 21:31:32 +0000 (00:31 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:06 +0000 (16:22 -0700)
68/4af47693eee170af3d04886ba7163aa72fd085 [new file with mode: 0644]

diff --git a/68/4af47693eee170af3d04886ba7163aa72fd085 b/68/4af47693eee170af3d04886ba7163aa72fd085
new file mode 100644 (file)
index 0000000..c44ec06
--- /dev/null
@@ -0,0 +1,182 @@
+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 5B1436DE0939\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:33 -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.501\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.501 tagged_above=-999 required=5 tests=[AWL=1.221, \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 xvbMdbS-KIAS for <notmuch@notmuchmail.org>;\r
+ Sat, 18 Jun 2016 14:33:25 -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 9D4686DE02D5 for\r
+ <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:08 -0700 (PDT)\r
+Received: by mail-wm0-f67.google.com with SMTP id c82so2551242wme.3\r
+ for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:08 -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=b7QIri2DRzrN84f47fMDjjHS9mXCicuyiHHSgXz6VoA=;\r
+ b=Jmo5VTKxRIXOS5ma6o46n77pZ+HGYVp3CHBCRavfLggv2KaI6D4plv1aAq7eIQfuv3\r
+ poQ39mlrIl0/DXzy2GmwYOgXO0B+Q4325CO8i+EfBwpwkIAiBdZym+iN/okCNrAsGJeG\r
+ OSzFVcaqFenddjaJ5ZPpCUMgj5DmyHfoxnGfUDYgfxtBewSOY4y27p1rSxJyZ2JgDFml\r
+ 0NU9dMW7E4QFlJfH7dJk7XyshypHZtIKJbXNkClIKTpKTym7cxKsnI3xEfS7CnqkXyzb\r
+ aZ3Tjg0aKcjDTps4X1uZz/wcJK5+mZaHKvJugptlRp/ywSPLqdxSXAz/pCu3CzOqOSCP\r
+ n1ow==\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=b7QIri2DRzrN84f47fMDjjHS9mXCicuyiHHSgXz6VoA=;\r
+ b=cQryTRIO2OH3RFiklUGjl9ifXSzPtQZar78g8BsqD/ShNZR3hqWeVAOw5lAEFFP33l\r
+ vHHv4ocrccrAH+PmJjSjP/08G8RvCw2/0Shu9vxWDHm7ILyGsfEg0PwcmQYD3eyAZPUq\r
+ AJF+BP0j4Vs5WxfPMiS4i0+5GRphZ+N7V4L4/9T7F+wFO2G18GTz9k/UZP5llvZ8VKwr\r
+ kQBvx45FUT4Jn62Iw6swds63sQyOlHCsXwjI9ai6U5MWSc+kkOdFjgaXW4rX2B00GA+U\r
+ hhr6e3MQIdMRH0Z/VjyqE0ywgKrGftEVn0/KZhAVkD6V2goTlWt09IW0Hb4Yz3NE2Bmz\r
+ JYag==\r
+X-Gm-Message-State:\r
+ ALyK8tL+8qSEuxyz49Oxf3psYe7ZcxU2ozH6Mt5Hs5rOLls6wOifeOnAtTw+yuhNXyo7Ew==\r
+X-Received: by 10.28.41.4 with SMTP id p4mr4233760wmp.33.1466285587225;\r
+ Sat, 18 Jun 2016 14:33:07 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c37a-44.dhcp.inet.fi.\r
+ [88.195.122.44])\r
+ by smtp.gmail.com with ESMTPSA id g195sm5452697wme.23.2016.06.18.14.33.06\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 18 Jun 2016 14:33:06 -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 6/7] cli/reply: reuse create_reply_message() also for\r
+ headers-only format\r
+Date: Sun, 19 Jun 2016 00:31:32 +0300\r
+Message-Id:\r
+ <954d507f5a0eff70abb2d818850b62763c6dfffe.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:33 -0000\r
+\r
+Add an option for "limited" headers for the (slightly misleadingly\r
+named) headers-only format. There should be no functional changes.\r
+---\r
+ notmuch-reply.c | 46 +++++++++++++++-------------------------------\r
+ 1 file changed, 15 insertions(+), 31 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index c2d7402d40ae..daad453efb09 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -520,13 +520,17 @@ static GMimeMessage *\r
+ create_reply_message(void *ctx,\r
+                    notmuch_config_t *config,\r
+                    notmuch_message_t *message,\r
+-                   notmuch_bool_t reply_all)\r
++                   notmuch_bool_t reply_all,\r
++                   notmuch_bool_t limited)\r
+ {\r
+     const char *subject, *from_addr = NULL;\r
+     const char *in_reply_to, *orig_references, *references;\r
\r
+-    /* The 1 means we want headers in a "pretty" order. */\r
+-    GMimeMessage *reply = g_mime_message_new (1);\r
++    /*\r
++     * Use the below header order for limited headers, "pretty" order\r
++     * otherwise.\r
++     */\r
++    GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1);\r
+     if (reply == NULL) {\r
+       fprintf (stderr, "Out of memory\n");\r
+       return NULL;\r
+@@ -549,6 +553,10 @@ create_reply_message(void *ctx,\r
+     from_addr = add_recipients_from_message (reply, config,\r
+                                            message, reply_all);\r
\r
++    /* The above is all that is needed for limited headers. */\r
++    if (limited)\r
++      return reply;\r
++\r
+     /*\r
+      * Sadly, there is no standard way to find out to which email\r
+      * address a mail was delivered - what is in the headers depends\r
+@@ -605,7 +613,7 @@ notmuch_reply_format_default(void *ctx,\r
+     if (mime_node_open (ctx, message, &params->crypto, &node))\r
+       return 1;\r
\r
+-    reply = create_reply_message (ctx, config, message, reply_all);\r
++    reply = create_reply_message (ctx, config, message, reply_all, FALSE);\r
+     if (!reply)\r
+       return 1;\r
\r
+@@ -632,7 +640,7 @@ notmuch_reply_format_sprinter(void *ctx,\r
+     if (mime_node_open (ctx, message, &params->crypto, &node))\r
+       return 1;\r
\r
+-    reply = create_reply_message (ctx, config, message, reply_all);\r
++    reply = create_reply_message (ctx, config, message, reply_all, FALSE);\r
+     if (!reply)\r
+       return 1;\r
\r
+@@ -665,34 +673,10 @@ notmuch_reply_format_headers_only(void *ctx,\r
+                                 unused (sprinter_t *sp))\r
+ {\r
+     GMimeMessage *reply;\r
+-    const char *in_reply_to, *orig_references, *references;\r
\r
+-    /* The 0 means we do not want headers in a "pretty" order. */\r
+-    reply = g_mime_message_new (0);\r
+-    if (reply == NULL) {\r
+-      fprintf (stderr, "Out of memory\n");\r
++    reply = create_reply_message (ctx, config, message, reply_all, TRUE);\r
++    if (!reply)\r
+       return 1;\r
+-    }\r
+-\r
+-    in_reply_to = talloc_asprintf (ctx, "<%s>",\r
+-                                 notmuch_message_get_message_id (message));\r
+-\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
+-\r
+-    /*\r
+-     * We print In-Reply-To followed by References because git\r
+-     * format-patch treats them specially. Git does not interpret the\r
+-     * other headers specially.\r
+-     */\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), "References", references);\r
+-\r
+-    (void)add_recipients_from_message (reply, config, message, reply_all);\r
\r
+     show_reply_headers (reply);\r
\r
+-- \r
+2.1.4\r
+\r