]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-tag.c
build: drop the -Wswitch-enum warning
[notmuch] / notmuch-tag.c
index bd56fd14a4699b74f5567f6ac0e3d4284a49600e..d15f1eda481fe0a6931afbb61de38289249642db 100644 (file)
@@ -203,6 +203,17 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
            break;
        }
        if (argv[i][0] == '+' || argv[i][0] == '-') {
+           if (argv[i][0] == '+' && argv[i][1] == '\0') {
+               fprintf(stderr, "Error: tag names cannot be empty.\n");
+               return 1;
+           }
+           if (argv[i][0] == '+' && argv[i][1] == '-') {
+               /* This disallows adding the non-removable tag "-" and
+                * enables notmuch tag to take long options in the
+                * future. */
+               fprintf(stderr, "Error: tag names must not start with '-'.\n");
+               return 1;
+           }
            tag_ops[tag_ops_count].tag = argv[i] + 1;
            tag_ops[tag_ops_count].remove = (argv[i][0] == '-');
            tag_ops_count++;
@@ -229,9 +240,8 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
     if (config == NULL)
        return 1;
 
-    notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
-                                    NOTMUCH_DATABASE_MODE_READ_WRITE);
-    if (notmuch == NULL)
+    if (notmuch_database_open (notmuch_config_get_database_path (config),
+                              NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))
        return 1;
 
     synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);