From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 873216DE01D0 for ; Tue, 13 Sep 2016 10:16:35 -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.586 X-Spam-Level: X-Spam-Status: No, score=-0.586 tagged_above=-999 required=5 tests=[AWL=0.134, 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 a-2hlQ2nXeYz for ; Tue, 13 Sep 2016 10:16:35 -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 E36526DE0B2F for ; Tue, 13 Sep 2016 10:16:23 -0700 (PDT) Received: by mail-wm0-f67.google.com with SMTP id b187so19217051wme.0 for ; Tue, 13 Sep 2016 10:16:23 -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=mztSrYGmbARruZLeuS1xm+PmdroTkQwQKX/NgbDed03Q7/TMYhocXG6ihC2cS29Bcw 1kA5KQapry9LPrncuLkGdy7Foq3A65qOOqKGVadfJUzQOayOgmg7Zt2NGtovqCTUY7t5 kNDD/W1jOQWf8yPVKzQSfqFaCuWNE0aOQ3sRNdwqlYdjwJBdda2SzprFWne4vfkL8LHE R2DV3y26+7m2ib7y0YAfooxMTXjP0zlQSHGnToxUuR0doc0ifF7DPH5h29EZwVx/VEwr mTB9Lmy4rmL3BKNxpfq9CDcEDtRDIV0s7Mr36FmcUkVjzu+NP7X5SCoztKwPAFNrq35E uVUA== 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=hyi9E1ARqZLGSfhOr/BoAi9CgGgNSgN28s1BVgV2yt23/ALY7gCdrsh1+0JX5D4R+7 NZd1GFUuFd5nJFqn9MCDh6idAKLLVJmEBiWlTRvhWte5czsbuooBpoPCodrGwW4jYZ5Y D/UwnEsyEiplBeO8CqeYgFZmbnCnGEzWYR+6PUNUS8SjpalQm9k7uwjxGiRbwN+rTM// +FmNPQGo5ztXD/nug3cBcwAQypGJUSgOBz8M1URN+ZnyqmVdg5Mknoj+zwYC39E+Iy8F s0AlZANuDl4FrkjZ323Wa7EeQCcO1lgEE0t44G0CO1eWoWH1HHAsUFzDqp82z72hTOyn vnpA== X-Gm-Message-State: AE9vXwNdt5wOvGCF9X7H2NJHxBO3gPKua03olee3A07tot6SjB/ys7xtrRejrz8hzemIrg== X-Received: by 10.28.207.73 with SMTP id f70mr1732899wmg.29.1473786981952; Tue, 13 Sep 2016 10:16:21 -0700 (PDT) Received: from localhost (mobile-access-bcee6a-45.dhcp.inet.fi. [188.238.106.45]) by smtp.gmail.com with ESMTPSA id va3sm23977477wjb.18.2016.09.13.10.16.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2016 10:16:21 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v3 08/15] cli/reply: reuse create_reply_message() also for headers-only format Date: Tue, 13 Sep 2016 20:14:15 +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.22 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: Tue, 13 Sep 2016 17:16:35 -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