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>
maint
Ben Peart 2018-09-18 23:29:34 +00:00 committed by Junio C Hamano
parent ac6e12f9b7
commit 5aacc63f1e
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include "pathspec.h" #include "pathspec.h"
#include "dir.h" #include "dir.h"
#include "fsmonitor.h" #include "fsmonitor.h"
#include "config.h"


#ifdef NO_PTHREADS #ifdef NO_PTHREADS
static void preload_index(struct index_state *index, static void preload_index(struct index_state *index,
@ -84,7 +85,7 @@ static void preload_index(struct index_state *index,
return; return;


threads = index->cache_nr / THREAD_COST; 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; threads = 2;
if (threads < 2) if (threads < 2)
return; return;