From: Jani Nikula Date: Sat, 13 Aug 2016 11:37:28 +0000 (+0300) Subject: [PATCH v2 04/14] cli/reply: unify reply format functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a877d93c7c87469f7c895650e60cc62f41e9e551;p=notmuch-archives.git [PATCH v2 04/14] cli/reply: unify reply format functions --- diff --git a/f6/59684433ac6c742395c059f2e457bcc8155b1d b/f6/59684433ac6c742395c059f2e457bcc8155b1d new file mode 100644 index 000000000..b8f22e7dd --- /dev/null +++ b/f6/59684433ac6c742395c059f2e457bcc8155b1d @@ -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 6D5466DE39D0 + for ; Sat, 13 Aug 2016 04:39:28 -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.573 +X-Spam-Level: +X-Spam-Status: No, score=-0.573 tagged_above=-999 required=5 tests=[AWL=0.147, + 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 HasmXwsrR4Nj for ; + Sat, 13 Aug 2016 04:39:20 -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 6C0D36DE38CC for + ; Sat, 13 Aug 2016 04:39:09 -0700 (PDT) +Received: by mail-wm0-f67.google.com with SMTP id i5so2016567wmg.2 + for ; Sat, 13 Aug 2016 04:39:09 -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=A9EvdMo1gWTnr9njPkRGF3tNzmC3/1oY9b6TEpsPHuRheWB1XiOflkgyP5o9qRmO/C + sE9HIouW87BErHX6R5f6xncLEYSmTme6O9tx40PSyUzc8PvKpe1cWemtHxFltaRmh1pt + dkSFPaef22O4ptcf8QY20mBUMS+yXL464p7nRv3FHoLB7+pRifecQoAt5B0xiCJrty3+ + IjAxuhZ/0uahiV8lBzI4uL93Yx12POixQtchNBiro9ecB7zkRSx62whajv0VVCMTKWEh + AUy+iEg66oiYkzhpqRXEmYevp2E+ZLRYwJM1IzGPZQ0fziSGq0EZhIiRqZrGFavYXX3j + 3++g== +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=Ylyhs/FN+gvw7sCXiVvemC+c5wyuGhdgWlJ/Vp6GCP7W+tQo8MaRp/K4jgAM4+dbWp + aypHN2Gu8/RHxgB/FgS6WYGlcIm50rnoh46KjZO7c6mRIBtBqfy3VeVdMCX4wspJtHst + pLOomKzHEqNXELTv5idZ+lMsZ9PXv8NoYV4btBTNyvIHP9nuYHYFWpC1X76tPBvSXEf6 + 7+88FAtb2HVr9JVVfWjZ7g6VcuK4udadLpVRs/x7L9GFOd0isnNcZ7FmC7nmgeghU4nc + gV8RObrs0z0e1H3HIMdzD0y+PbEkLgQ8l8Xq3DD3PpeHWG4qm8419wF6AUFZ8N7SOhsr + b4Uw== +X-Gm-Message-State: + AEkoouvfRT/ATr5D4p2GC+9c0c5VDSo4Iyj2Xnt+5MtktSZ4UGDqjEAgtTLE6XMn1JwUkQ== +X-Received: by 10.28.134.203 with SMTP id i194mr3599877wmd.22.1471088348099; + Sat, 13 Aug 2016 04:39:08 -0700 (PDT) +Received: from localhost (mobile-access-bcee63-250.dhcp.inet.fi. + [188.238.99.250]) + by smtp.gmail.com with ESMTPSA id m62sm6757895wmm.24.2016.08.13.04.39.07 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 13 Aug 2016 04:39:07 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Cc: Daniel Kahn Gillmor , + jani@nikula.org +Subject: [PATCH v2 04/14] cli/reply: unify reply format functions +Date: Sat, 13 Aug 2016 14:37:28 +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:28 -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 +