unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] cli: bail out and propagate tagging errors in notmuch tag
@ 2013-01-08 21:41 Jani Nikula
  2013-01-08 23:51 ` Tomi Ollila
  2013-01-10  3:14 ` David Bremner
  0 siblings, 2 replies; 8+ messages in thread
From: Jani Nikula @ 2013-01-08 21:41 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] cli: bail out and propagate tagging errors in notmuch tag
  2013-01-08 21:41 [PATCH] cli: bail out and propagate tagging errors in notmuch tag Jani Nikula
@ 2013-01-08 23:51 ` Tomi Ollila
  2013-01-10  3:14 ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2013-01-08 23:51 UTC (permalink / raw)
  To: Jani Nikula, notmuch

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cli: bail out and propagate tagging errors in notmuch tag
  2013-01-08 21:41 [PATCH] cli: bail out and propagate tagging errors in notmuch tag Jani Nikula
  2013-01-08 23:51 ` Tomi Ollila
@ 2013-01-10  3:14 ` David Bremner
  2013-01-10  4:26   ` Tomi Ollila
  1 sibling, 1 reply; 8+ messages in thread
From: David Bremner @ 2013-01-10  3:14 UTC (permalink / raw)
  To: Jani Nikula, notmuch

Jani Nikula <jani@nikula.org> writes:
> +	if (ret)
> +	    break;

I amended this to (ret != NOTMUCH_STATUS_SUCCESS) 

There are a few different families of status codes flying around here,
and I liked the extra documentation.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cli: bail out and propagate tagging errors in notmuch tag
  2013-01-10  3:14 ` David Bremner
@ 2013-01-10  4:26   ` Tomi Ollila
  2013-01-10 12:08     ` David Bremner
  2013-01-19 13:17     ` [PATCH] notmuch-tag: initialize with enum instead of 0 david
  0 siblings, 2 replies; 8+ messages in thread
From: Tomi Ollila @ 2013-01-10  4:26 UTC (permalink / raw)
  To: David Bremner, Jani Nikula, notmuch

On Thu, Jan 10 2013, David Bremner <david@tethera.net> wrote:

> Jani Nikula <jani@nikula.org> writes:
>> +	if (ret)
>> +	    break;
>
> I amended this to (ret != NOTMUCH_STATUS_SUCCESS) 
>
> There are a few different families of status codes flying around here,
> and I liked the extra documentation.

That sure is a good point, should follow-up patch do this:

-    int ret = 0;
+    int ret = NOTMUCH_STATUS_SUCCESS;

?

> d

Tomi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cli: bail out and propagate tagging errors in notmuch tag
  2013-01-10  4:26   ` Tomi Ollila
@ 2013-01-10 12:08     ` David Bremner
  2013-01-19 13:17     ` [PATCH] notmuch-tag: initialize with enum instead of 0 david
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2013-01-10 12:08 UTC (permalink / raw)
  To: Tomi Ollila, Jani Nikula, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:
>
> That sure is a good point, should follow-up patch do this:
>
> -    int ret = 0;
> +    int ret = NOTMUCH_STATUS_SUCCESS;
>

sure.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] notmuch-tag: initialize with enum instead of 0.
  2013-01-10  4:26   ` Tomi Ollila
  2013-01-10 12:08     ` David Bremner
@ 2013-01-19 13:17     ` david
  2013-01-19 17:29       ` Tomi Ollila
  2013-01-19 18:34       ` David Bremner
  1 sibling, 2 replies; 8+ messages in thread
From: david @ 2013-01-19 13:17 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

This is just a cosmetic fix to make the "type" of ret more clear.
---
 notmuch-tag.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/notmuch-tag.c b/notmuch-tag.c
index b54c55d..d9daf8f 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -97,7 +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;
+    int ret = NOTMUCH_STATUS_SUCCESS;
 
     /* Optimize the query so it excludes messages that already have
      * the specified set of tags. */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] notmuch-tag: initialize with enum instead of 0.
  2013-01-19 13:17     ` [PATCH] notmuch-tag: initialize with enum instead of 0 david
@ 2013-01-19 17:29       ` Tomi Ollila
  2013-01-19 18:34       ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2013-01-19 17:29 UTC (permalink / raw)
  To: david, notmuch; +Cc: David Bremner

On Sat, Jan 19 2013, david@tethera.net wrote:

> From: David Bremner <bremner@debian.org>
>
> This is just a cosmetic fix to make the "type" of ret more clear.
> ---
>  notmuch-tag.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/notmuch-tag.c b/notmuch-tag.c
> index b54c55d..d9daf8f 100644
> --- a/notmuch-tag.c
> +++ b/notmuch-tag.c
> @@ -97,7 +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;
> +    int ret = NOTMUCH_STATUS_SUCCESS;

LGTM.

Tomi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] notmuch-tag: initialize with enum instead of 0.
  2013-01-19 13:17     ` [PATCH] notmuch-tag: initialize with enum instead of 0 david
  2013-01-19 17:29       ` Tomi Ollila
@ 2013-01-19 18:34       ` David Bremner
  1 sibling, 0 replies; 8+ messages in thread
From: David Bremner @ 2013-01-19 18:34 UTC (permalink / raw)
  To: notmuch

david@tethera.net writes:

> From: David Bremner <bremner@debian.org>
>
> This is just a cosmetic fix to make the "type" of ret more clear.

Pushed. I even caught the '.' and the end of the commit subject.
No idea why that is so hard for me.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-19 18:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08 21:41 [PATCH] cli: bail out and propagate tagging errors in notmuch tag Jani Nikula
2013-01-08 23:51 ` Tomi Ollila
2013-01-10  3:14 ` David Bremner
2013-01-10  4:26   ` Tomi Ollila
2013-01-10 12:08     ` David Bremner
2013-01-19 13:17     ` [PATCH] notmuch-tag: initialize with enum instead of 0 david
2013-01-19 17:29       ` Tomi Ollila
2013-01-19 18:34       ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).