Merge branch 'sg/revision-parser-skip-prefix'
[gitweb.git] / builtin / add.c
index 36cad00ae6ddad2b181da0b51294e1fe86aef788..d9a2491e48f16d9ef7de5c05008f8c7e6a5e64b2 100644 (file)
@@ -17,6 +17,7 @@
 #include "revision.h"
 #include "bulk-checkin.h"
 #include "argv-array.h"
+#include "submodule.h"
 
 static const char * const builtin_add_usage[] = {
        N_("git add [<options>] [--] <pathspec>..."),
@@ -135,7 +136,7 @@ static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec,
                        *dst++ = entry;
        }
        dir->nr = dst - dir->entries;
-       add_pathspec_matches_against_index(pathspec, seen);
+       add_pathspec_matches_against_index(pathspec, &the_index, seen);
        return seen;
 }
 
@@ -379,16 +380,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        if (read_cache() < 0)
                die(_("index file corrupt"));
 
+       die_in_unpopulated_submodule(&the_index, prefix);
+
        /*
         * Check the "pathspec '%s' did not match any files" block
         * below before enabling new magic.
         */
        parse_pathspec(&pathspec, 0,
                       PATHSPEC_PREFER_FULL |
-                      PATHSPEC_SYMLINK_LEADING_PATH |
-                      PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE,
+                      PATHSPEC_SYMLINK_LEADING_PATH,
                       prefix, argv);
 
+       die_path_inside_submodule(&the_index, &pathspec);
+
        if (add_new_files) {
                int baselen;
 
@@ -414,7 +418,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                int i;
 
                if (!seen)
-                       seen = find_pathspecs_matching_against_index(&pathspec);
+                       seen = find_pathspecs_matching_against_index(&pathspec, &the_index);
 
                /*
                 * file_exists() assumes exact match