Code

clarify some error messages wrt unknown object types
[git.git] / builtin-add.c
index febb75ed994b5edc51afc60e2d46483fa9e273f2..c8a114fefb60a106dccffda5c703f2f00fa30ce9 100644 (file)
@@ -3,8 +3,6 @@
  *
  * Copyright (C) 2006 Linus Torvalds
  */
-#include <fnmatch.h>
-
 #include "cache.h"
 #include "builtin.h"
 #include "dir.h"
@@ -94,9 +92,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
        newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);
 
-       if (read_cache() < 0)
-               die("index file corrupt");
-
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
 
@@ -131,6 +126,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                return 0;
        }
 
+       if (read_cache() < 0)
+               die("index file corrupt");
+
        for (i = 0; i < dir.nr; i++)
                add_file_to_index(dir.entries[i]->name, verbose);