[PATCH v2 05/14] cli/reply: reorganize create_reply_message()
authorJani Nikula <jani@nikula.org>
Sat, 13 Aug 2016 11:37:29 +0000 (14:37 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:25 +0000 (16:22 -0700)
18/4fab97e3debfb20edfb7639f5bb90f8c61ba61 [new file with mode: 0644]

diff --git a/18/4fab97e3debfb20edfb7639f5bb90f8c61ba61 b/18/4fab97e3debfb20edfb7639f5bb90f8c61ba61
new file mode 100644 (file)
index 0000000..ed4e4cf
--- /dev/null
@@ -0,0 +1,157 @@
+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 886FE6DE39F9\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:30 -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.573\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.573 tagged_above=-999 required=5 tests=[AWL=0.147,\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 NQTTjdzCLUrp for <notmuch@notmuchmail.org>;\r
+ Sat, 13 Aug 2016 04:39:22 -0700 (PDT)\r
+Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
+ [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 4CEDE6DE38D1 for\r
+ <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:11 -0700 (PDT)\r
+Received: by mail-wm0-f65.google.com with SMTP id i5so2016665wmg.2\r
+ for <notmuch@notmuchmail.org>; Sat, 13 Aug 2016 04:39:11 -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=fbeShvw4M66SrxkIEgtBhkFxVPPUGacbY8QcRCVt1P8=;\r
+ b=D40EZr4nheHCp+XA042QJMLrpm/bjnHXiZh+5QgkIjxYZQ/CAUVRujJltzHoqNrUVM\r
+ +5hlNASWdIDDb/2k7cUX8loo8pdugb7odH5jiKRXyXhzAFWkVWlsUbtNtDjiCVg5mpyg\r
+ Lem6er+u6xqNWfFLl+PUnbQ7iiVu0Z0ebw+3GDNf8NfmTgvw+gvg0mfFSQ1kuOHntxqU\r
+ VdGYg6+Vkm12DMNJ6kBwrpvbWKMdhNSPohMHim5F85UOnMtntr2O2qeQFRIzknLTRFrI\r
+ D7pbcIYllFfWncyjeA3vCO4yrfW6E6YnOvGgEYc0kl3dySnoTvuwBtLlLQk6joNnfqGk\r
+ vgAA==\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=fbeShvw4M66SrxkIEgtBhkFxVPPUGacbY8QcRCVt1P8=;\r
+ b=B6OxzOgwdAfP93kCON8Ou8rrzwLWK5KEV1C/MoK435NCOEw5vjZ0bgITaXA5A30gAZ\r
+ 9TrzRjB+FaCyH2MiqRVkEhdnzwBNatVYnC7AN81G4nmGC/jGtyHQ+r7TeTSyppbWR4Sg\r
+ zfj9/wCCA1eyfndA1oA0vYUl/Y1D/fzIUjbDUb/hP4E3FksxBlfcd5fSsnBc9/9Iq9tA\r
+ CryhQe21cCtnx8t6KRW8kq+Skxs9BkGz56W8mO7CRO1brHrIWo7pL4VJiLOSdpvYXsYB\r
+ TXlSn09cHAKg/lsNLGAsg8zWGwwnUAzxx3w8inZV7M9+9kL65lchUcaCY5XSycBeBUiu\r
+ v+HA==\r
+X-Gm-Message-State:\r
+ AEkooutgaTA8K7L2TDA5IDumZ20jXLQCulLVJZaCBfJQD4JlGLu03L+6JbuwZMfc+Qw34Q==\r
+X-Received: by 10.194.135.205 with SMTP id pu13mr24239190wjb.37.1471088349934;\r
+  Sat, 13 Aug 2016 04:39:09 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee63-250.dhcp.inet.fi.\r
+ [188.238.99.250])\r
+ by smtp.gmail.com with ESMTPSA id p1sm11776270wjd.37.2016.08.13.04.39.09\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 13 Aug 2016 04:39:09 -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 05/14] cli/reply: reorganize create_reply_message()\r
+Date: Sat, 13 Aug 2016 14:37:29 +0300\r
+Message-Id:\r
+ <b56dcdd19ee572f1b895ba634644e0f3bfb69e11.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:30 -0000\r
+\r
+Again, in preparation for later unification, reorganize\r
+create_reply_message() to be more similar to the open coded version in\r
+the headers-only format reply code. Due to "pretty" header ordering,\r
+there should be no change in output. There should be no functional\r
+changes.\r
+---\r
+ notmuch-reply.c | 45 +++++++++++++++++++++------------------------\r
+ 1 file changed, 21 insertions(+), 24 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 4b97ffa4f096..eb07405591fd 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -532,12 +532,20 @@ create_reply_message(void *ctx,\r
+       return NULL;\r
+     }\r
\r
+-    subject = notmuch_message_get_header (message, "subject");\r
+-    if (subject) {\r
+-      if (strncasecmp (subject, "Re:", 3))\r
+-          subject = talloc_asprintf (ctx, "Re: %s", subject);\r
+-      g_mime_message_set_subject (reply, subject);\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
++    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
++    g_mime_object_set_header (GMIME_OBJECT (reply), "References", references);\r
\r
+     from_addr = add_recipients_from_message (reply, config,\r
+                                            message, reply_all);\r
+@@ -572,25 +580,14 @@ create_reply_message(void *ctx,\r
+     from_addr = talloc_asprintf (ctx, "%s <%s>",\r
+                                notmuch_config_get_user_name (config),\r
+                                from_addr);\r
+-    g_mime_object_set_header (GMIME_OBJECT (reply),\r
+-                            "From", from_addr);\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),\r
+-                            "In-Reply-To", in_reply_to);\r
++    g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr);\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
+-    g_mime_object_set_header (GMIME_OBJECT (reply),\r
+-                            "References", references);\r
++    subject = notmuch_message_get_header (message, "subject");\r
++    if (subject) {\r
++      if (strncasecmp (subject, "Re:", 3))\r
++          subject = talloc_asprintf (ctx, "Re: %s", subject);\r
++      g_mime_message_set_subject (reply, subject);\r
++    }\r
\r
+     return reply;\r
+ }\r
+-- \r
+2.1.4\r
+\r