Skip to content

Commit 19b6958

Browse files
committed
squash! add: use preload-index and fscache for performance
We need to keep the call to read_cache() before parsing the pathspecs (and hence cannot use the pathspecs to limit any preload) because parse_pathspec() is using the index to determine whether a pathspec is, in fact, in a submodule. If we would not read the index first, parse_pathspec() would not error out on a path that is inside a submodule, and t7400-submodule-basic.sh would fail with not ok 47 - do not add files from a submodule We still want the nice preload performance boost, though, so we simply call read_cache_preload(&pathspecs) after parsing the pathspecs. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b194d6b commit 19b6958

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

builtin/add.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
376376
return 0;
377377
}
378378

379+
if (read_cache() < 0)
380+
die(_("index file corrupt"));
381+
379382
/*
380383
* Check the "pathspec '%s' did not match any files" block
381384
* below before enabling new magic.
@@ -387,8 +390,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
387390
prefix, argv);
388391

389392
enable_fscache(1);
390-
if (read_cache_preload(&pathspec) < 0)
391-
die(_("index file corrupt"));
393+
/* We do not really re-read the index, but update the up-to-date flags */
394+
preload_index(&the_index, &pathspec);
392395

393396
if (add_new_files) {
394397
int baselen;

0 commit comments

Comments
 (0)