preload-index: use git_env_bool() not getenv() for customization
authorBen Peart <benpeart@microsoft.com>
Tue, 18 Sep 2018 23:29:34 +0000 (23:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Sep 2018 17:39:04 +0000 (10:39 -0700)
GIT_FORCE_PRELOAD_TEST is only checked for presence by using getenv().
Use git_env_bool() instead so that GIT_FORCE_PRELOAD_TEST=false can
work as expected.

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
preload-index.c
index 71cd2437a3b33b343696bf96067603e8dc9e4464..0a4e2933bb6eca181b529c288aa9ac017138c349 100644 (file)
@@ -5,6 +5,7 @@
 #include "pathspec.h"
 #include "dir.h"
 #include "fsmonitor.h"
+#include "config.h"
 
 #ifdef NO_PTHREADS
 static void preload_index(struct index_state *index,
@@ -84,7 +85,7 @@ 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"))
+       if ((index->cache_nr > 1) && (threads < 2) && git_env_bool("GIT_FORCE_PRELOAD_TEST", 0))
                threads = 2;
        if (threads < 2)
                return;