From: Jani Nikula Date: Sat, 18 Jun 2016 21:31:29 +0000 (+0300) Subject: [PATCH 3/7] cli/reply: unify reply format functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b5702fe5df048dd883c3e45727dc918ea7cb2688;p=notmuch-archives.git [PATCH 3/7] cli/reply: unify reply format functions --- diff --git a/8b/3cfa8da8c1778678354868ddd43c18b5050ad1 b/8b/3cfa8da8c1778678354868ddd43c18b5050ad1 new file mode 100644 index 000000000..bdf0629dd --- /dev/null +++ b/8b/3cfa8da8c1778678354868ddd43c18b5050ad1 @@ -0,0 +1,149 @@ +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 BDF6E6DE091F + for ; Sat, 18 Jun 2016 14:33:18 -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.563 +X-Spam-Level: +X-Spam-Status: No, score=-0.563 tagged_above=-999 required=5 tests=[AWL=0.157, + 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 AZgEMTa7VEHQ for ; + Sat, 18 Jun 2016 14:33:11 -0700 (PDT) +Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com + [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id A8D9E6DE0231 for + ; Sat, 18 Jun 2016 14:33:03 -0700 (PDT) +Received: by mail-wm0-f68.google.com with SMTP id a66so396352wme.2 + for ; Sat, 18 Jun 2016 14:33:03 -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=mz2de6cLXojScvGRGmcz0RhTYF2mOcaPT9Nzasi4nKQ=; + b=Magt06EtBBNQajN6ARVORMpNbPD+WBAFAsBD9NAY4duKNM5n+GV4NjeDTcm9w7A/0A + CfF2BUyZuOpRNV39V43nxlXXQSKtEHZ3BC61AglzXJOFCeva9r/kN5E28jxk1OLfB+Rk + WDVCDmHzPe5BneHwqWHT7zn+NMBnEGYbix+oKQbADI/1X4qWrDOxp0Pt/LxuOCcsZfpT + aruT+3z+JVSbtX8HkK+P/HgZL8HPZDzqrUM/FJu17zgr4EDSFtw60SZzGr7aXAPnysUt + aO3BlSiloCoWcLgAsuYjzxLR0R9Vqtq2iJ56Xp9tkApDE5Zs/uOajuyVCyjaV+EY+mDi + h0bQ== +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=mz2de6cLXojScvGRGmcz0RhTYF2mOcaPT9Nzasi4nKQ=; + b=iez6qS+3pyPkhRJCq3Fjo7fiMoGHFVwOjzktGjFqD5kRWRJkA90vroxNRBQ72xiDIA + t38gB61VcmcjR6N8o36E4QLoPC3VsCJH+N9I2Px7jcYhwJQUubsuZCpRQ17kEUIZIZRU + /usvL0Fq96mRTI+zLwEQOOABsCJgQKVgZ/ydH4wsq5fMyQBZ9cbEfZnzRr5KvaVPdYlc + um+0RCEjhrsDI1Y3Hhz+TPLM4lkCtu67kjJlLGnxYM86Kx81CaPKb9DwF2YFupyAVUEB + qnYiqn8HOYP5kXEMCreduiQfCQgYKXv57W461irzIj0lYwpEhfmmluHzA/A1nn0Lh2xF + 1/XQ== +X-Gm-Message-State: + ALyK8tIR8J75WEW27jw0NuIqZclt1GaKXKZZrsm6s7BPk6fh7NeD7/Kr7pijEZSFI2HWXw== +X-Received: by 10.28.199.205 with SMTP id x196mr4126286wmf.96.1466285582370; + Sat, 18 Jun 2016 14:33:02 -0700 (PDT) +Received: from localhost (mobile-access-bcee4e-81.dhcp.inet.fi. + [188.238.78.81]) + by smtp.gmail.com with ESMTPSA id r130sm1676742wmf.20.2016.06.18.14.33.01 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 18 Jun 2016 14:33:01 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Cc: jani@nikula.org, + Daniel Kahn Gillmor +Subject: [PATCH 3/7] cli/reply: unify reply format functions +Date: Sun, 19 Jun 2016 00:31:29 +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, 18 Jun 2016 21:33:18 -0000 + +Prepare for further future unification by making the code similar. The +only functional change is that errors in mime_node_open() also break +execution in default reply format. +--- + notmuch-reply.c | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +diff --git a/notmuch-reply.c b/notmuch-reply.c +index 5adbab624ad7..4b97ffa4f096 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -604,20 +604,20 @@ notmuch_reply_format_default(void *ctx, + unused (sprinter_t *sp)) + { + GMimeMessage *reply; +- mime_node_t *root; ++ mime_node_t *node; ++ ++ if (mime_node_open (ctx, message, ¶ms->crypto, &node)) ++ return 1; + + reply = create_reply_message (ctx, config, message, reply_all); + if (!reply) + return 1; + + show_reply_headers (reply); ++ format_part_reply (node); + + g_object_unref (G_OBJECT (reply)); +- +- if (mime_node_open (ctx, message, ¶ms->crypto, &root) == NOTMUCH_STATUS_SUCCESS) { +- format_part_reply (root); +- talloc_free (root); +- } ++ talloc_free (node); + + return 0; + } +@@ -633,7 +633,7 @@ notmuch_reply_format_sprinter(void *ctx, + GMimeMessage *reply; + mime_node_t *node; + +- if (mime_node_open (ctx, message, ¶ms->crypto, &node) != NOTMUCH_STATUS_SUCCESS) ++ if (mime_node_open (ctx, message, ¶ms->crypto, &node)) + return 1; + + reply = create_reply_message (ctx, config, message, reply_all); +@@ -645,7 +645,6 @@ notmuch_reply_format_sprinter(void *ctx, + /* The headers of the reply message we've created */ + sp->map_key (sp, "reply-headers"); + format_headers_sprinter (sp, reply, TRUE); +- g_object_unref (G_OBJECT (reply)); + + /* Start the original */ + sp->map_key (sp, "original"); +@@ -654,6 +653,9 @@ notmuch_reply_format_sprinter(void *ctx, + /* End */ + sp->end (sp); + ++ g_object_unref (G_OBJECT (reply)); ++ talloc_free (node); ++ + return 0; + } + +-- +2.1.4 +