Skip to content

Commit 9235a6c

Browse files
committed
Merge branch 'bp/add-diff-files-optim'
"git add" needs to internally run "diff-files" equivalent, and the codepath learned the same optimization as "diff-files" has to run lstat(2) in parallel to find which paths have been updated in the working tree. * bp/add-diff-files-optim: add: speed up cmd_add() by utilizing read_cache_preload()
2 parents 39d23df + d1664e7 commit 9235a6c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

builtin/add.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
445445
return 0;
446446
}
447447

448-
if (read_cache() < 0)
449-
die(_("index file corrupt"));
450-
451-
die_in_unpopulated_submodule(&the_index, prefix);
452-
453448
/*
454449
* Check the "pathspec '%s' did not match any files" block
455450
* below before enabling new magic.
@@ -459,6 +454,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
459454
PATHSPEC_SYMLINK_LEADING_PATH,
460455
prefix, argv);
461456

457+
if (read_cache_preload(&pathspec) < 0)
458+
die(_("index file corrupt"));
459+
460+
die_in_unpopulated_submodule(&the_index, prefix);
462461
die_path_inside_submodule(&the_index, &pathspec);
463462

464463
if (add_new_files) {

0 commit comments

Comments
 (0)