]> git.ipfire.org Git - thirdparty/git.git/commitdiff
environment: remove the global variable 'core_preload_index'
authorAyush Chandekar <ayu.chandekar@gmail.com>
Tue, 10 Jun 2025 13:02:20 +0000 (18:32 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Jun 2025 17:10:38 +0000 (10:10 -0700)
The global variable 'core_preload_index' is used in a single function
named 'preload_index()' in "preload-index.c". Move its declaration inside
that function, removing unnecessary global state.

This change is part of an ongoing effort to eliminate global variables,
improve modularity and help libify the codebase.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
environment.c
environment.h
preload-index.c

index b18b5617fcd05d146aec7b44edd50ff53523be39..eb60c293ab31331983f685290a99819b693c4abe 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1595,11 +1595,6 @@ static int git_default_core_config(const char *var, const char *value,
                return 0;
        }
 
-       if (!strcmp(var, "core.preloadindex")) {
-               core_preload_index = git_config_bool(var, value);
-               return 0;
-       }
-
        if (!strcmp(var, "core.createobject")) {
                if (!value)
                        return config_error_nonbool(var);
index c61d773e7e8ff0dc1bc9b312dee0ca1f153e110d..7bf0390a3355d3838c1b3baab93051bed5686790 100644 (file)
@@ -113,9 +113,6 @@ const char *comment_line_str = "#";
 char *comment_line_str_to_free;
 int auto_comment_line_char;
 
-/* Parallel index stat data preload? */
-int core_preload_index = 1;
-
 /* This is set by setup_git_directory_gently() and/or git_default_config() */
 char *git_work_tree_cfg;
 
index 3d98461a06f70228a9a1b160173291c04a0ba9b8..9a3d05d414a7ad316a4b45a7498e6773457e8afd 100644 (file)
@@ -155,7 +155,6 @@ extern int pack_compression_level;
 extern unsigned long pack_size_limit_cfg;
 extern int max_allowed_tree_depth;
 
-extern int core_preload_index;
 extern int precomposed_unicode;
 extern int protect_hfs;
 extern int protect_ntfs;
index 40ab2abafb8de500a5f2ec678a584a5fd5e1bc16..9fee4cc3aaeebfec2d5ad0fd47eaf3498343bd90 100644 (file)
@@ -19,6 +19,7 @@
 #include "repository.h"
 #include "symlinks.h"
 #include "trace2.h"
+#include "config.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
@@ -111,6 +112,9 @@ void preload_index(struct index_state *index,
        struct thread_data data[MAX_PARALLEL];
        struct progress_data pd;
        int t2_sum_lstat = 0;
+       int core_preload_index = 1;
+
+       repo_config_get_bool(the_repository, "core.preloadindex", &core_preload_index);
 
        if (!HAVE_THREADS || !core_preload_index)
                return;