legacy-rebase: backport -C<n> and --whitespace=<option> checks
[gitweb.git] / preload-index.c
index 2541b307e8bafc7280c0ded43346a0d723af1768..222792ccbc39b6166a75c702525c396b77c2299e 100644 (file)
@@ -5,10 +5,11 @@
 #include "pathspec.h"
 #include "dir.h"
 #include "fsmonitor.h"
+#include "config.h"
 #include "progress.h"
 
 #ifdef NO_PTHREADS
-static void preload_index(struct index_state *index,
+void preload_index(struct index_state *index,
                          const struct pathspec *pathspec,
                          unsigned int refresh_flags)
 {
@@ -99,23 +100,23 @@ static void *preload_thread(void *_data)
        return NULL;
 }
 
-static void preload_index(struct index_state *index,
-                         const struct pathspec *pathspec,
-                         unsigned int refresh_flags)
+void preload_index(struct index_state *index,
+                  const struct pathspec *pathspec,
+                  unsigned int refresh_flags)
 {
        int threads, i, work, offset;
        struct thread_data data[MAX_PARALLEL];
-       uint64_t start = getnanotime();
        struct progress_data pd;
 
        if (!core_preload_index)
                return;
 
        threads = index->cache_nr / THREAD_COST;
-       if ((index->cache_nr > 1) && (threads < 2) && getenv("GIT_FORCE_PRELOAD_TEST"))
+       if ((index->cache_nr > 1) && (threads < 2) && git_env_bool("GIT_TEST_PRELOAD_INDEX", 0))
                threads = 2;
        if (threads < 2)
                return;
+       trace_performance_enter();
        if (threads > MAX_PARALLEL)
                threads = MAX_PARALLEL;
        offset = 0;
@@ -148,7 +149,7 @@ static void preload_index(struct index_state *index,
        }
        stop_progress(&pd.progress);
 
-       trace_performance_since(start, "preload index");
+       trace_performance_leave("preload index");
 }
 #endif