Re: Possible addtions to notmuch new ?
[notmuch-archives.git] / 53 / f7db3574f2c7d3b7d981853dd108c1506c0816
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 16055431FAF\r
6         for <notmuch@notmuchmail.org>; Tue,  8 Jan 2013 13:42:03 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id hDWIVwtJGREf for <notmuch@notmuchmail.org>;\r
16         Tue,  8 Jan 2013 13:42:02 -0800 (PST)\r
17 Received: from mail-la0-f46.google.com (mail-la0-f46.google.com\r
18         [209.85.215.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 605D0431FAE\r
21         for <notmuch@notmuchmail.org>; Tue,  8 Jan 2013 13:42:02 -0800 (PST)\r
22 Received: by mail-la0-f46.google.com with SMTP id fq13so1019536lab.19\r
23         for <notmuch@notmuchmail.org>; Tue, 08 Jan 2013 13:42:00 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=x-received:from:to:subject:date:message-id:x-mailer\r
27         :x-gm-message-state;\r
28         bh=4zv6aZ/NT0dkhk8tAF4ZK5nIeRgf0QXC0OJWdkx2QNE=;\r
29         b=l/AI7x8xjMRn1hVQiCtihDjLNPfHcnFlf75HI4kyP2deSX2/1fdfZeG8QIiBcaiqrT\r
30         mL8htqWHJhLFY5195sg6TdUPqbNMfNVOqrl4LDC/b3k42bqpRftDnYAjeDBed2tlqw2s\r
31         ORcDJWeHy2YDZG8cChBGMFhxI75KsS4czlgKncPlVABsjgQFgFGxmNqajRUeAquK2lNy\r
32         OALn3nbKd9wLWKJfp10tiWHqcCkSdJJFBtinI5W/ixNJnlnWvRD4VyNhQD0gqRWz7X5v\r
33         aZ1EEzz2jIxH8rnTg1eDa7i2StFh5WVqFu6JqBfoKjcR07gFfE0Ae+e4oc1lBDvr2fhM\r
34         eG7g==\r
35 X-Received: by 10.112.24.226 with SMTP id x2mr26885797lbf.97.1357681319399;\r
36         Tue, 08 Jan 2013 13:41:59 -0800 (PST)\r
37 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
38         [80.223.81.27])\r
39         by mx.google.com with ESMTPS id n7sm23149636lbz.5.2013.01.08.13.41.57\r
40         (version=SSLv3 cipher=OTHER); Tue, 08 Jan 2013 13:41:58 -0800 (PST)\r
41 From: Jani Nikula <jani@nikula.org>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH] cli: bail out and propagate tagging errors in notmuch tag\r
44 Date: Tue,  8 Jan 2013 23:41:54 +0200\r
45 Message-Id: <1357681314-29384-1-git-send-email-jani@nikula.org>\r
46 X-Mailer: git-send-email 1.7.10.4\r
47 X-Gm-Message-State:\r
48  ALoCoQnmdwiBwDl2B1xsAwcLCIkFCfMEQ5aMZf4JKNoVcFXKnYpaJGhkwNnPY+SoKWWSakpvLglb\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Tue, 08 Jan 2013 21:42:03 -0000\r
62 \r
63 Checking and propagating tag_op_list_apply() errors is especially\r
64 important with batch tagging, as the processing of the batch input\r
65 would not stop otherwise. Additionally this sets the exit code, which\r
66 is useful in scripts.\r
67 ---\r
68  notmuch-tag.c |    7 +++++--\r
69  1 file changed, 5 insertions(+), 2 deletions(-)\r
70 \r
71 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
72 index 4272426..16b1668 100644\r
73 --- a/notmuch-tag.c\r
74 +++ b/notmuch-tag.c\r
75 @@ -97,6 +97,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
76      notmuch_query_t *query;\r
77      notmuch_messages_t *messages;\r
78      notmuch_message_t *message;\r
79 +    int ret = 0;\r
80  \r
81      /* Optimize the query so it excludes messages that already have\r
82       * the specified set of tags. */\r
83 @@ -119,13 +120,15 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
84          notmuch_messages_valid (messages) && ! interrupted;\r
85          notmuch_messages_move_to_next (messages)) {\r
86         message = notmuch_messages_get (messages);\r
87 -       tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);\r
88 +       ret = tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);\r
89         notmuch_message_destroy (message);\r
90 +       if (ret)\r
91 +           break;\r
92      }\r
93  \r
94      notmuch_query_destroy (query);\r
95  \r
96 -    return interrupted;\r
97 +    return ret || interrupted;\r
98  }\r
99  \r
100  static int\r
101 -- \r
102 1.7.10.4\r
103 \r