From 394cb1c46d91a1bb28df9cc4a563e1115cc9af34 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 18 Nov 2009 13:43:38 -0800 Subject: 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 --- notmuch-reply.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'notmuch-reply.c') 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"); -- cgit v1.2.3