preload-index: use git_env_bool() not getenv() for customization

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>

Ben Peart committed Sep 18, 2018 at 23:29 UTC 5aacc63f1e8414a12105faa7647c4c11f8acd02d
1 file changed +2 -1
preload-index.c
+2 -1
@@ -5,6 +5,7 @@
5 #include "pathspec.h"
6 #include "dir.h"
7 #include "fsmonitor.h"
8 +#include "config.h"
9
10 #ifdef NO_PTHREADS
11 static void preload_index(struct index_state *index,
@@ -84,7 +85,7 @@ static void preload_index(struct index_state *index,
85 return;
86
87 threads = index->cache_nr / THREAD_COST;
87 - if ((index->cache_nr > 1) && (threads < 2) && getenv("GIT_FORCE_PRELOAD_TEST"))
88 + if ((index->cache_nr > 1) && (threads < 2) && git_env_bool("GIT_FORCE_PRELOAD_TEST", 0))
89 threads = 2;
90 if (threads < 2)
91 return;