[PATCH 1/3] notmuch-restore: fix return value propagation
authordavid <david@tethera.net>
Mon, 17 Dec 2012 03:59:46 +0000 (23:59 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:28 +0000 (09:52 -0800)
3b/3384f8e6276dd8c51d7a614af15f726ceb5c21 [new file with mode: 0644]

diff --git a/3b/3384f8e6276dd8c51d7a614af15f726ceb5c21 b/3b/3384f8e6276dd8c51d7a614af15f726ceb5c21
new file mode 100644 (file)
index 0000000..ca43445
--- /dev/null
@@ -0,0 +1,108 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 63647431FC2\r
+       for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 20:00:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 07O+a5-mTrVd for <notmuch@notmuchmail.org>;\r
+       Sun, 16 Dec 2012 20:00:51 -0800 (PST)\r
+Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
+       (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id DF16C431FC4\r
+       for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 20:00:46 -0800 (PST)\r
+Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net\r
+       ([142.167.90.129] helo=zancas.localnet)\r
+       by tesseract.cs.unb.ca with esmtpsa\r
+       (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1TkRsk-0008LV-5d; Mon, 17 Dec 2012 00:00:46 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.80)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1TkRse-0000ng-N0; Mon, 17 Dec 2012 00:00:40 -0400\r
+From: david@tethera.net\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/3] notmuch-restore: fix return value propagation\r
+Date: Sun, 16 Dec 2012 23:59:46 -0400\r
+Message-Id: <1355716788-2940-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1355716788-2940-1-git-send-email-david@tethera.net>\r
+References: <1355716788-2940-1-git-send-email-david@tethera.net>\r
+X-Spam_bar: -\r
+Cc: David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 17 Dec 2012 04:00:52 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+Previously notmuch_restore_command returned 0 if tag_message returned\r
+a non-zero (failure) value. This is wrong, since non-zero status\r
+indicates something mysterious went wrong with retrieving the message,\r
+or applying it.\r
+\r
+There was also a failure to check or propagate the return value from\r
+tag_op_list_apply in tag_message.\r
+---\r
+ notmuch-restore.c |   13 ++++++++++---\r
+ 1 file changed, 10 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/notmuch-restore.c b/notmuch-restore.c\r
+index 40596a8..5a02328 100644\r
+--- a/notmuch-restore.c\r
++++ b/notmuch-restore.c\r
+@@ -25,6 +25,9 @@\r
\r
+ static regex_t regex;\r
\r
++/* Non-zero return indicates an error in retrieving the message,\r
++ * or in applying the tags.\r
++ */\r
+ static int\r
+ tag_message (unused (void *ctx),\r
+            notmuch_database_t *notmuch,\r
+@@ -48,7 +51,7 @@ tag_message (unused (void *ctx),\r
+     /* In order to detect missing messages, this check/optimization is\r
+      * intentionally done *after* first finding the message. */\r
+     if ((flags & TAG_FLAG_REMOVE_ALL) || tag_op_list_size (tag_ops))\r
+-      tag_op_list_apply (message, tag_ops, flags);\r
++      ret = tag_op_list_apply (message, tag_ops, flags);\r
\r
+     notmuch_message_destroy (message);\r
\r
+@@ -231,8 +234,12 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
+       if (ret > 0)\r
+           continue;\r
\r
+-      if (ret < 0 || tag_message (ctx, notmuch, query_string,\r
+-                                  tag_ops, flags))\r
++      if (ret < 0)\r
++          break;\r
++\r
++      ret = tag_message (line_ctx, notmuch, query_string,\r
++                         tag_ops, flags);\r
++      if (ret)\r
+           break;\r
\r
+     }  while ((line_len = getline (&line, &line_size, input)) != -1);\r
+-- \r
+1.7.10.4\r
+\r