Skip to content

Commit b1d47b4

Browse files
ayu-chgitster
authored andcommitted
environment: remove the global variable 'core_preload_index'
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 <[email protected]> Mentored-by: Ghanshyam Thakkar <[email protected]> Signed-off-by: Ayush Chandekar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c0e625 commit b1d47b4

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

config.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,11 +1595,6 @@ static int git_default_core_config(const char *var, const char *value,
15951595
return 0;
15961596
}
15971597

1598-
if (!strcmp(var, "core.preloadindex")) {
1599-
core_preload_index = git_config_bool(var, value);
1600-
return 0;
1601-
}
1602-
16031598
if (!strcmp(var, "core.createobject")) {
16041599
if (!value)
16051600
return config_error_nonbool(var);

environment.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ const char *comment_line_str = "#";
113113
char *comment_line_str_to_free;
114114
int auto_comment_line_char;
115115

116-
/* Parallel index stat data preload? */
117-
int core_preload_index = 1;
118-
119116
/* This is set by setup_git_directory_gently() and/or git_default_config() */
120117
char *git_work_tree_cfg;
121118

environment.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ extern int pack_compression_level;
155155
extern unsigned long pack_size_limit_cfg;
156156
extern int max_allowed_tree_depth;
157157

158-
extern int core_preload_index;
159158
extern int precomposed_unicode;
160159
extern int protect_hfs;
161160
extern int protect_ntfs;

preload-index.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "repository.h"
2020
#include "symlinks.h"
2121
#include "trace2.h"
22+
#include "config.h"
2223

2324
/*
2425
* Mostly randomly chosen maximum thread counts: we
@@ -111,6 +112,9 @@ void preload_index(struct index_state *index,
111112
struct thread_data data[MAX_PARALLEL];
112113
struct progress_data pd;
113114
int t2_sum_lstat = 0;
115+
int core_preload_index = 1;
116+
117+
repo_config_get_bool(the_repository, "core.preloadindex", &core_preload_index);
114118

115119
if (!HAVE_THREADS || !core_preload_index)
116120
return;

0 commit comments

Comments
 (0)