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