From: Jani Nikula Date: Sat, 13 Aug 2016 11:37:31 +0000 (+0300) Subject: [PATCH v2 07/14] cli/reply: reuse create_reply_message() also for headers-only format X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=edcde7ee7041509489763f0d304ea0f1b429a750;p=notmuch-archives.git [PATCH v2 07/14] cli/reply: reuse create_reply_message() also for headers-only format --- diff --git a/c9/394d6942e881100d6477e87a2763794090a207 b/c9/394d6942e881100d6477e87a2763794090a207 new file mode 100644 index 000000000..7294f3518 --- /dev/null +++ b/c9/394d6942e881100d6477e87a2763794090a207 @@ -0,0 +1,182 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id D72186DE3A57 + for ; Sat, 13 Aug 2016 04:39:43 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.574 +X-Spam-Level: +X-Spam-Status: No, score=-0.574 tagged_above=-999 required=5 tests=[AWL=0.146, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 4MD4dv6l_A22 for ; + Sat, 13 Aug 2016 04:39:36 -0700 (PDT) +Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com + [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 5575F6DE38DA for + ; Sat, 13 Aug 2016 04:39:14 -0700 (PDT) +Received: by mail-wm0-f66.google.com with SMTP id q128so2021111wma.1 + for ; Sat, 13 Aug 2016 04:39:14 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=nikula-org.20150623.gappssmtp.com; s=20150623; + h=from:to:cc:subject:date:message-id:in-reply-to:references + :in-reply-to:references; + bh=b7QIri2DRzrN84f47fMDjjHS9mXCicuyiHHSgXz6VoA=; + b=IJZLuaO+Amv1DR5W5YJoLF9Rdn4SvuxlXUHR4ejxeVn/s8FRstUG5m4Q/Agwjfgv0U + ooCWDHb0Ebmsw6UxHRIQGhLlLNa7sj/M88MR85egAFtA7CxEA0ep6RnQ4cxQNeN044nV + s+RBKMpqj74ZdyfyRPimvCpnnN6jfI4KofRgTZZdDAQsDGkBoFCi6VS2K2i9ze5LtUXQ + KJt310W+WPZqEufwx/MfMV/lOyO3noFgwQUsA4dCjAATcC9ecdidSWZr/dexkiaCZuSG + e7yVT4bfDcE7DbsYlzQLg1ql4yXSxyTYzn+Jm5FQN4H5y2/2Z/93hLBt4T1+1naDMEPL + +Kug== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references:in-reply-to:references; + bh=b7QIri2DRzrN84f47fMDjjHS9mXCicuyiHHSgXz6VoA=; + b=CnuDcdrol9wx/hRAomK7rdnwhno6Fub5O2x4SDCRV9zaKuNesTfCCfbvU+8QCy4fhd + uLWOfvDmwir34Vjmg9mrT68WGjUvlMQ7GLa7FdaAuU5GKHzpjYIH8t2xp+yfmzgrPszA + t3LUwQ8fTgw148YlT7lwWCQhktcEhU97hxjAijxJ2NxuljgCiCouWkfNNUkTIRMB1YQq + 02DCUvTFLy0DxaDfdApfhCzE1ml3JIZacnZxQ+xwuJ3jzmuDXyfmnte6LKJ6F6MN7PO6 + qI7r7wSvh7psdn+rtxTMoqKxAcqIoyuoeThZ081x7VjEz0dz8qpu0zpeLWDECcHyaq6X + DTvg== +X-Gm-Message-State: + AEkooutix+7JQA8qIkopAJpJ1H69K7ClZYo1TBMMxwkaeVMPuoRaXi0amXydR4KMumgiwg== +X-Received: by 10.194.35.42 with SMTP id e10mr20014626wjj.107.1471088352970; + Sat, 13 Aug 2016 04:39:12 -0700 (PDT) +Received: from localhost (mobile-access-bcee63-250.dhcp.inet.fi. + [188.238.99.250]) + by smtp.gmail.com with ESMTPSA id bw9sm11773689wjc.33.2016.08.13.04.39.12 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 13 Aug 2016 04:39:12 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Cc: Daniel Kahn Gillmor , + jani@nikula.org +Subject: [PATCH v2 07/14] cli/reply: reuse create_reply_message() also for + headers-only format +Date: Sat, 13 Aug 2016 14:37:31 +0300 +Message-Id: + +X-Mailer: git-send-email 2.1.4 +In-Reply-To: +References: +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 13 Aug 2016 11:39:43 -0000 + +Add an option for "limited" headers for the (slightly misleadingly +named) headers-only format. There should be no functional changes. +--- + notmuch-reply.c | 46 +++++++++++++++------------------------------- + 1 file changed, 15 insertions(+), 31 deletions(-) + +diff --git a/notmuch-reply.c b/notmuch-reply.c +index c2d7402d40ae..daad453efb09 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -520,13 +520,17 @@ static GMimeMessage * + create_reply_message(void *ctx, + notmuch_config_t *config, + notmuch_message_t *message, +- notmuch_bool_t reply_all) ++ notmuch_bool_t reply_all, ++ notmuch_bool_t limited) + { + const char *subject, *from_addr = NULL; + const char *in_reply_to, *orig_references, *references; + +- /* The 1 means we want headers in a "pretty" order. */ +- GMimeMessage *reply = g_mime_message_new (1); ++ /* ++ * Use the below header order for limited headers, "pretty" order ++ * otherwise. ++ */ ++ GMimeMessage *reply = g_mime_message_new (limited ? 0 : 1); + if (reply == NULL) { + fprintf (stderr, "Out of memory\n"); + return NULL; +@@ -549,6 +553,10 @@ create_reply_message(void *ctx, + from_addr = add_recipients_from_message (reply, config, + message, reply_all); + ++ /* The above is all that is needed for limited headers. */ ++ if (limited) ++ return reply; ++ + /* + * Sadly, there is no standard way to find out to which email + * address a mail was delivered - what is in the headers depends +@@ -605,7 +613,7 @@ notmuch_reply_format_default(void *ctx, + if (mime_node_open (ctx, message, ¶ms->crypto, &node)) + return 1; + +- reply = create_reply_message (ctx, config, message, reply_all); ++ reply = create_reply_message (ctx, config, message, reply_all, FALSE); + if (!reply) + return 1; + +@@ -632,7 +640,7 @@ notmuch_reply_format_sprinter(void *ctx, + if (mime_node_open (ctx, message, ¶ms->crypto, &node)) + return 1; + +- reply = create_reply_message (ctx, config, message, reply_all); ++ reply = create_reply_message (ctx, config, message, reply_all, FALSE); + if (!reply) + return 1; + +@@ -665,34 +673,10 @@ notmuch_reply_format_headers_only(void *ctx, + unused (sprinter_t *sp)) + { + GMimeMessage *reply; +- const char *in_reply_to, *orig_references, *references; + +- /* The 0 means we do not want headers in a "pretty" order. */ +- reply = g_mime_message_new (0); +- if (reply == NULL) { +- fprintf (stderr, "Out of memory\n"); ++ reply = create_reply_message (ctx, config, message, reply_all, TRUE); ++ if (!reply) + return 1; +- } +- +- in_reply_to = talloc_asprintf (ctx, "<%s>", +- notmuch_message_get_message_id (message)); +- +- g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to); +- +- orig_references = notmuch_message_get_header (message, "references"); +- +- /* +- * We print In-Reply-To followed by References because git +- * format-patch treats them specially. Git does not interpret the +- * other headers specially. +- */ +- references = talloc_asprintf (ctx, "%s%s%s", +- orig_references ? orig_references : "", +- orig_references ? " " : "", +- in_reply_to); +- g_mime_object_set_header (GMIME_OBJECT (reply), "References", references); +- +- (void)add_recipients_from_message (reply, config, message, reply_all); + + show_reply_headers (reply); + +-- +2.1.4 +