]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-new.c
util: Fix two corner-cases in boolean term quoting function
[notmuch] / notmuch-new.c
index cd744891c2439982ac3851435aa66ea1ed7e07fa..82acf695353e614e97c1afc91a079f54d20a95f9 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include "notmuch-client.h"
+#include "tag-util.h"
 
 #include <unistd.h>
 
@@ -173,7 +174,7 @@ dirent_type (const char *path, const struct dirent *entry)
     char *abspath;
     int err, saved_errno;
 
-#ifdef _DIRENT_HAVE_D_TYPE
+#if HAVE_D_TYPE
     /* Mapping from d_type to stat mode_t.  We omit DT_LNK so that
      * we'll fall through to stat and get the real file type. */
     static const mode_t modes[] = {
@@ -918,7 +919,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
     struct sigaction action;
     _filename_node_t *f;
     int opt_index;
-    int i;
+    unsigned int i;
     notmuch_bool_t timer_is_active = FALSE;
     notmuch_bool_t no_hooks = FALSE;
     notmuch_bool_t quiet = FALSE, verbose = FALSE;
@@ -950,6 +951,17 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
     add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
     db_path = notmuch_config_get_database_path (config);
 
+    for (i = 0; i < add_files_state.new_tags_length; i++) {
+       const char *error_msg;
+
+       error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
+       if (error_msg) {
+           fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
+                    add_files_state.new_tags[i], error_msg);
+           return EXIT_FAILURE;
+       }
+    }
+
     if (!no_hooks) {
        ret = notmuch_run_hook (db_path, "pre-new");
        if (ret)