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 C6B4D431FB6 for ; Tue, 8 Jan 2013 15:51:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 lpusfPIcN-Wr for ; Tue, 8 Jan 2013 15:51:19 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id E11C3431FAE for ; Tue, 8 Jan 2013 15:51:18 -0800 (PST) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id C0BD51000D0; Wed, 9 Jan 2013 01:51:08 +0200 (EET) From: Tomi Ollila To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH] cli: bail out and propagate tagging errors in notmuch tag In-Reply-To: <1357681314-29384-1-git-send-email-jani@nikula.org> References: <1357681314-29384-1-git-send-email-jani@nikula.org> User-Agent: Notmuch/0.14+247~gf806a85 (http://notmuchmail.org) Emacs/24.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain 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 23:51:20 -0000 On Tue, Jan 08 2013, Jani Nikula wrote: > 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. > --- LGTM. Tomi > 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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch