summaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorBen Peart <benpeart@microsoft.com>2018-11-02 13:30:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-02 15:43:04 (GMT)
commitd1664e73ad96aa08735bf81d48ec0fb6d196cc3e (patch)
tree9c4339d85512d15000a398dafecbc77ab2b9d78a /builtin/add.c
parentd582ea202b626dcc6c3b01e1e11a296d9badd730 (diff)
downloadgit-d1664e73ad96aa08735bf81d48ec0fb6d196cc3e.zip
git-d1664e73ad96aa08735bf81d48ec0fb6d196cc3e.tar.gz
git-d1664e73ad96aa08735bf81d48ec0fb6d196cc3e.tar.bz2
add: speed up cmd_add() by utilizing read_cache_preload()
During an "add", a call is made to run_diff_files() which calls check_removed() for each index-entry. The preload_index() code distributes some of the costs across multiple threads. Because the files checked are restricted to pathspec, adding individual files makes no measurable impact but on a Windows repo with ~200K files, 'git add .' drops from 6.3 seconds to 3.3 seconds for a 47% savings. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/builtin/add.c b/builtin/add.c
index ad49806..f65c172 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -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) {