]> git.notmuchmail.org Git - notmuch/commitdiff
Make reply/show/tag all require at least one search term
authorKeith Packard <keithp@keithp.com>
Wed, 18 Nov 2009 21:43:38 +0000 (13:43 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 18 Nov 2009 22:37:35 +0000 (23:37 +0100)
In particular, notmuch tag -inbox "" tended to take a long time to
run, happened if you hit 'a' on a blank line in the search view and
probably didn't have the desired effect.

Signed-off-by: Keith Packard <keithp@keithp.com>
notmuch-reply.c
notmuch-show.c
notmuch-tag.c

index 4a4a782b1636a269aa505f8b560f06eaa2cd337c..31e2c87cfe07651dec79d7c5fdc3286c0d865e61 100644 (file)
@@ -196,16 +196,21 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
     if (config == NULL)
        return 1;
 
-    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
-    if (notmuch == NULL)
-       return 1;
-
     query_string = query_string_from_args (ctx, argc, argv);
     if (query_string == NULL) {
        fprintf (stderr, "Out of memory\n");
        return 1;
     }
 
+    if (*query_string == '\0') {
+       fprintf (stderr, "Error: notmuch reply requires at least one search term.\n");
+       return 1;
+    }
+
+    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
+    if (notmuch == NULL)
+       return 1;
+
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL) {
        fprintf (stderr, "Out of memory\n");
index 30b7df596854763f236a2c6fa9aeda7891bb9d7a..96f287408fa12c2f729f3cc3f68a81fd533c46aa 100644 (file)
@@ -196,16 +196,21 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     if (config == NULL)
        return 1;
 
-    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
-    if (notmuch == NULL)
-       return 1;
-
     query_string = query_string_from_args (ctx, argc, argv);
     if (query_string == NULL) {
        fprintf (stderr, "Out of memory\n");
        return 1;
     }
 
+    if (*query_string == '\0') {
+       fprintf (stderr, "Error: notmuch show requires at least one search term.\n");
+       return 1;
+    }
+
+    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
+    if (notmuch == NULL)
+       return 1;
+
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL) {
        fprintf (stderr, "Out of memory\n");
index 7d92ec485eabc7233d176bc2b8374a81bde494c5..12ab86c58d8429229b27a870ec98962ea1e70304 100644 (file)
@@ -83,8 +83,10 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
        return 1;
     }
 
-    if (i == argc) {
-       fprintf (stderr, "Error: 'notmuch tag' requires at least one search term.\n");
+    query_string = query_string_from_args (ctx, argc - i, &argv[i]);
+
+    if (*query_string == '\0') {
+       fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");
        return 1;
     }
 
@@ -96,8 +98,6 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
     if (notmuch == NULL)
        return 1;
 
-    query_string = query_string_from_args (ctx, argc - i, &argv[i]);
-
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL) {
        fprintf (stderr, "Out of memory.\n");