From 5ee820087455365f6025cc45927bef8252ad562d Mon Sep 17 00:00:00 2001 From: Takuto Ikuta Date: Wed, 3 Jan 2018 13:22:52 +0900 Subject: [PATCH] checkout.c: enable fscache for checkout_entry This is to speed up git checkout for directory in very large repositories. Taking file stats while directory traversing is faster than stating to each files on windows. `git checkout .` in master branch of chromium repositry, having 284659 files, takes more than 18 seconds. This patch improved the time to around 4 seconds on my SSD laptop. Signed-off-by: Takuto Ikuta --- builtin/checkout.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/checkout.c b/builtin/checkout.c index fc4f8fd2ea29c7..257d64f7f16b53 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -21,6 +21,7 @@ #include "resolve-undo.h" #include "submodule-config.h" #include "submodule.h" +#include "fscache.h" static const char * const checkout_usage[] = { N_("git checkout [] "), @@ -360,6 +361,7 @@ static int checkout_paths(const struct checkout_opts *opts, state.istate = &the_index; enable_delayed_checkout(&state); + enable_fscache(1); for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; if (ce->ce_flags & CE_MATCHED) { @@ -374,6 +376,7 @@ static int checkout_paths(const struct checkout_opts *opts, pos = skip_same_name(ce, pos) - 1; } } + enable_fscache(0); errs |= finish_delayed_checkout(&state); if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))