aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Keith Packard <keithp@keithp.com>2009-11-18 13:43:38 -0800
committerGravatar Carl Worth <cworth@cworth.org>2009-11-18 23:37:35 +0100
commit394cb1c46d91a1bb28df9cc4a563e1115cc9af34 (patch)
tree8a20adcaa1bc49bf7a58d26f3a2981bc17cb6b6b
parent956917915f2cbeb43e04e9b98ad8301d0830c8c6 (diff)
Make reply/show/tag all require at least one search term
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>
-rw-r--r--notmuch-reply.c13
-rw-r--r--notmuch-show.c13
-rw-r--r--notmuch-tag.c8
3 files changed, 22 insertions, 12 deletions
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 4a4a782b..31e2c87c 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -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");
diff --git a/notmuch-show.c b/notmuch-show.c
index 30b7df59..96f28740 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -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");
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 7d92ec48..12ab86c5 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -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");