From ece360f20566ea9eac60de09d89971683a22f1ce Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 19 Jun 2016 00:31:32 +0300 Subject: [PATCH] [PATCH 6/7] cli/reply: reuse create_reply_message() also for headers-only format --- 68/4af47693eee170af3d04886ba7163aa72fd085 | 182 ++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 68/4af47693eee170af3d04886ba7163aa72fd085 diff --git a/68/4af47693eee170af3d04886ba7163aa72fd085 b/68/4af47693eee170af3d04886ba7163aa72fd085 new file mode 100644 index 000000000..c44ec0602 --- /dev/null +++ b/68/4af47693eee170af3d04886ba7163aa72fd085 @@ -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 5B1436DE0939 + for ; Sat, 18 Jun 2016 14:33:33 -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.501 +X-Spam-Level: +X-Spam-Status: No, score=0.501 tagged_above=-999 required=5 tests=[AWL=1.221, + 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 xvbMdbS-KIAS for ; + Sat, 18 Jun 2016 14:33:25 -0700 (PDT) +Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com + [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id 9D4686DE02D5 for + ; Sat, 18 Jun 2016 14:33:08 -0700 (PDT) +Received: by mail-wm0-f67.google.com with SMTP id c82so2551242wme.3 + for ; Sat, 18 Jun 2016 14:33:08 -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=Jmo5VTKxRIXOS5ma6o46n77pZ+HGYVp3CHBCRavfLggv2KaI6D4plv1aAq7eIQfuv3 + poQ39mlrIl0/DXzy2GmwYOgXO0B+Q4325CO8i+EfBwpwkIAiBdZym+iN/okCNrAsGJeG + OSzFVcaqFenddjaJ5ZPpCUMgj5DmyHfoxnGfUDYgfxtBewSOY4y27p1rSxJyZ2JgDFml + 0NU9dMW7E4QFlJfH7dJk7XyshypHZtIKJbXNkClIKTpKTym7cxKsnI3xEfS7CnqkXyzb + aZ3Tjg0aKcjDTps4X1uZz/wcJK5+mZaHKvJugptlRp/ywSPLqdxSXAz/pCu3CzOqOSCP + n1ow== +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=cQryTRIO2OH3RFiklUGjl9ifXSzPtQZar78g8BsqD/ShNZR3hqWeVAOw5lAEFFP33l + vHHv4ocrccrAH+PmJjSjP/08G8RvCw2/0Shu9vxWDHm7ILyGsfEg0PwcmQYD3eyAZPUq + AJF+BP0j4Vs5WxfPMiS4i0+5GRphZ+N7V4L4/9T7F+wFO2G18GTz9k/UZP5llvZ8VKwr + kQBvx45FUT4Jn62Iw6swds63sQyOlHCsXwjI9ai6U5MWSc+kkOdFjgaXW4rX2B00GA+U + hhr6e3MQIdMRH0Z/VjyqE0ywgKrGftEVn0/KZhAVkD6V2goTlWt09IW0Hb4Yz3NE2Bmz + JYag== +X-Gm-Message-State: + ALyK8tL+8qSEuxyz49Oxf3psYe7ZcxU2ozH6Mt5Hs5rOLls6wOifeOnAtTw+yuhNXyo7Ew== +X-Received: by 10.28.41.4 with SMTP id p4mr4233760wmp.33.1466285587225; + Sat, 18 Jun 2016 14:33:07 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c37a-44.dhcp.inet.fi. + [88.195.122.44]) + by smtp.gmail.com with ESMTPSA id g195sm5452697wme.23.2016.06.18.14.33.06 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 18 Jun 2016 14:33:06 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Cc: jani@nikula.org, + Daniel Kahn Gillmor +Subject: [PATCH 6/7] cli/reply: reuse create_reply_message() also for + headers-only format +Date: Sun, 19 Jun 2016 00:31:32 +0300 +Message-Id: + <954d507f5a0eff70abb2d818850b62763c6dfffe.1466284726.git.jani@nikula.org> +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, 18 Jun 2016 21:33:33 -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 + -- 2.26.2