preload-index: add override to enable testing preload-index
authorBen Peart <benpeart@microsoft.com>
Fri, 22 Sep 2017 16:35:38 +0000 (12:35 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 24 Sep 2017 01:39:40 +0000 (10:39 +0900)
By default, the preload index code path doesn't run unless there is a
minimum of 1000 files. To enable running the test suite and having it
execute the preload-index path, add an environment variable
(GIT_FORCE_PRELOAD_TEST) which will override that minimum and set it to 2.

This enables you run existing tests and have the core.preloadindex code
path execute as long as the test has at least 2 files by setting
GIT_FORCE_PRELOAD_TEXT=1 before running the test.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
preload-index.c
index 70a4c808783bab92b4b6319e3dbd8e16641b1918..75564c497a6e55f6f5f7d13d1ab25c40ed5ed423 100644 (file)
@@ -79,6 +79,8 @@ static void preload_index(struct index_state *index,
                return;
 
        threads = index->cache_nr / THREAD_COST;
+       if ((index->cache_nr > 1) && (threads < 2) && getenv("GIT_FORCE_PRELOAD_TEST"))
+               threads = 2;
        if (threads < 2)
                return;
        if (threads > MAX_PARALLEL)