[PATCH] cli: bail out and propagate tagging errors in notmuch tag
authorJani Nikula <jani@nikula.org>
Tue, 8 Jan 2013 21:41:54 +0000 (23:41 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:03 +0000 (09:53 -0800)
53/f7db3574f2c7d3b7d981853dd108c1506c0816 [new file with mode: 0644]

diff --git a/53/f7db3574f2c7d3b7d981853dd108c1506c0816 b/53/f7db3574f2c7d3b7d981853dd108c1506c0816
new file mode 100644 (file)
index 0000000..8182b0f
--- /dev/null
@@ -0,0 +1,103 @@
+Return-Path: <jani@nikula.org>\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 16055431FAF\r
+       for <notmuch@notmuchmail.org>; Tue,  8 Jan 2013 13:42:03 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 hDWIVwtJGREf for <notmuch@notmuchmail.org>;\r
+       Tue,  8 Jan 2013 13:42:02 -0800 (PST)\r
+Received: from mail-la0-f46.google.com (mail-la0-f46.google.com\r
+       [209.85.215.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 605D0431FAE\r
+       for <notmuch@notmuchmail.org>; Tue,  8 Jan 2013 13:42:02 -0800 (PST)\r
+Received: by mail-la0-f46.google.com with SMTP id fq13so1019536lab.19\r
+       for <notmuch@notmuchmail.org>; Tue, 08 Jan 2013 13:42:00 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=x-received:from:to:subject:date:message-id:x-mailer\r
+       :x-gm-message-state;\r
+       bh=4zv6aZ/NT0dkhk8tAF4ZK5nIeRgf0QXC0OJWdkx2QNE=;\r
+       b=l/AI7x8xjMRn1hVQiCtihDjLNPfHcnFlf75HI4kyP2deSX2/1fdfZeG8QIiBcaiqrT\r
+       mL8htqWHJhLFY5195sg6TdUPqbNMfNVOqrl4LDC/b3k42bqpRftDnYAjeDBed2tlqw2s\r
+       ORcDJWeHy2YDZG8cChBGMFhxI75KsS4czlgKncPlVABsjgQFgFGxmNqajRUeAquK2lNy\r
+       OALn3nbKd9wLWKJfp10tiWHqcCkSdJJFBtinI5W/ixNJnlnWvRD4VyNhQD0gqRWz7X5v\r
+       aZ1EEzz2jIxH8rnTg1eDa7i2StFh5WVqFu6JqBfoKjcR07gFfE0Ae+e4oc1lBDvr2fhM\r
+       eG7g==\r
+X-Received: by 10.112.24.226 with SMTP id x2mr26885797lbf.97.1357681319399;\r
+       Tue, 08 Jan 2013 13:41:59 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
+       [80.223.81.27])\r
+       by mx.google.com with ESMTPS id n7sm23149636lbz.5.2013.01.08.13.41.57\r
+       (version=SSLv3 cipher=OTHER); Tue, 08 Jan 2013 13:41:58 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] cli: bail out and propagate tagging errors in notmuch tag\r
+Date: Tue,  8 Jan 2013 23:41:54 +0200\r
+Message-Id: <1357681314-29384-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Gm-Message-State:\r
+ ALoCoQnmdwiBwDl2B1xsAwcLCIkFCfMEQ5aMZf4JKNoVcFXKnYpaJGhkwNnPY+SoKWWSakpvLglb\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: Tue, 08 Jan 2013 21:42:03 -0000\r
+\r
+Checking and propagating tag_op_list_apply() errors is especially\r
+important with batch tagging, as the processing of the batch input\r
+would not stop otherwise. Additionally this sets the exit code, which\r
+is useful in scripts.\r
+---\r
+ notmuch-tag.c |    7 +++++--\r
+ 1 file changed, 5 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-tag.c b/notmuch-tag.c\r
+index 4272426..16b1668 100644\r
+--- a/notmuch-tag.c\r
++++ b/notmuch-tag.c\r
+@@ -97,6 +97,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
+     notmuch_query_t *query;\r
+     notmuch_messages_t *messages;\r
+     notmuch_message_t *message;\r
++    int ret = 0;\r
\r
+     /* Optimize the query so it excludes messages that already have\r
+      * the specified set of tags. */\r
+@@ -119,13 +120,15 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
+        notmuch_messages_valid (messages) && ! interrupted;\r
+        notmuch_messages_move_to_next (messages)) {\r
+       message = notmuch_messages_get (messages);\r
+-      tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);\r
++      ret = tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);\r
+       notmuch_message_destroy (message);\r
++      if (ret)\r
++          break;\r
+     }\r
\r
+     notmuch_query_destroy (query);\r
\r
+-    return interrupted;\r
++    return ret || interrupted;\r
+ }\r
\r
+ static int\r
+-- \r
+1.7.10.4\r
+\r