Merge branch 'nd/the-index' into md/list-objects-filter-by-depth
[gitweb.git] / builtin / add.c
index 0b64bcdebe0f4581953adccf8addf1c3fd1eb61e..f65c1722993b62e93feb85e506dffbc77b7ce921 100644 (file)
@@ -110,7 +110,7 @@ int add_files_to_cache(const char *prefix,
        memset(&data, 0, sizeof(data));
        data.flags = flags;
 
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        setup_revisions(0, NULL, &rev, NULL);
        if (pathspec)
                copy_pathspec(&rev.prune_data, pathspec);
@@ -232,7 +232,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
        if (read_cache() < 0)
                die(_("Could not read the index"));
 
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        rev.diffopt.context = 7;
 
        argc = setup_revisions(argc, argv, &rev, NULL);
@@ -445,11 +445,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                return 0;
        }
 
-       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.
@@ -459,6 +454,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                       PATHSPEC_SYMLINK_LEADING_PATH,
                       prefix, argv);
 
+       if (read_cache_preload(&pathspec) < 0)
+               die(_("index file corrupt"));
+
+       die_in_unpopulated_submodule(&the_index, prefix);
        die_path_inside_submodule(&the_index, &pathspec);
 
        if (add_new_files) {