]> git.notmuchmail.org Git - notmuch/commitdiff
cli: make caller check tag count in parse_tag_command_line
authorJani Nikula <jani@nikula.org>
Sat, 9 Mar 2013 14:56:48 +0000 (16:56 +0200)
committerDavid Bremner <bremner@unb.ca>
Sat, 30 Mar 2013 22:33:40 +0000 (18:33 -0400)
notmuch-tag.c
tag-util.c

index 0e73197cfb59595f5e7782d3e3d1c79aec2066f9..bc61aab8673a532bd3f80526b77db5aedb4284e2 100644 (file)
@@ -233,6 +233,11 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
        if (parse_tag_command_line (config, argc - opt_index, argv + opt_index,
                                    &query_string, tag_ops))
            return 1;
+
+       if (tag_op_list_size (tag_ops) == 0) {
+           fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");
+           return 1;
+       }
     }
 
     if (notmuch_database_open (notmuch_config_get_database_path (config),
index 701d329794b59a9c13f43a4e257ba752c944454a..c5f585950921af59659dddf8d635c95ae1853a2c 100644 (file)
@@ -188,11 +188,6 @@ parse_tag_command_line (void *ctx, int argc, char **argv,
        tag_op_list_append (tag_ops, argv[i] + 1, is_remove);
     }
 
-    if (tag_op_list_size (tag_ops) == 0) {
-       fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");
-       return TAG_PARSE_INVALID;
-    }
-
     *query_str = query_string_from_args (ctx, argc - i, &argv[i]);
 
     if (*query_str == NULL || **query_str == '\0') {