environment: move "check_stat" into `struct repo_config_values`

The `core.checkstat` configuration is currently stored in the global variable `check_stat`, which makes it shared across repository instances within a single process. Store it instead in `repo_config_values`, where eagerly‑parsed repository configuration lives. `core.checkstat` is parsed eagerly because it controls how `match_stat_data()` and related functions decide file freshness; a lazy parse could lead to unexpected behavior or complicate libification. This preserves the existing eager‑parsing behavior while tying the value to the repository it was read from, avoiding cross‑repository state leakage, and continuing the effort to reduce reliance on global configuration state. Update all references to use `repo_config_values()`. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Usman Akinyemi <usmanakinyemi202@gmail.com> Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Olamide Caleb Bello committed Jun 2, 2026 at 18:09 UTC 88505ed63711eca184409dfd949437c7e41f994e
4 files changed +11 -10
entry.c
+2 -1
@@ -443,7 +443,8 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen)
443 static void mark_colliding_entries(const struct checkout *state,
444 struct cache_entry *ce, struct stat *st)
445 {
446 - int trust_ino = check_stat;
446 + struct repo_config_values *cfg = repo_config_values(the_repository);
447 + int trust_ino = cfg->check_stat;
448
449 #if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)
450 trust_ino = 0;
environment.c
+3 -3
@@ -42,7 +42,6 @@ static int pack_compression_seen;
42 static int zlib_compression_seen;
43
44 int trust_executable_bit = 1;
45 -int check_stat = 1;
45 int has_symlinks = 1;
46 int minimum_abbrev = 4, default_abbrev = -1;
47 int ignore_case;
@@ -315,9 +314,9 @@ int git_default_core_config(const char *var, const char *value,
314 if (!value)
315 return config_error_nonbool(var);
316 if (!strcasecmp(value, "default"))
318 - check_stat = 1;
317 + cfg->check_stat = 1;
318 else if (!strcasecmp(value, "minimal"))
320 - check_stat = 0;
319 + cfg->check_stat = 0;
320 else
321 return error(_("invalid value for '%s': '%s'"),
322 var, value);
@@ -721,4 +720,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
720 cfg->apply_sparse_checkout = 0;
721 cfg->branch_track = BRANCH_TRACK_REMOTE;
722 cfg->trust_ctime = 1;
723 + cfg->check_stat = 1;
724 }
environment.h
+1 -1
@@ -92,6 +92,7 @@ struct repo_config_values {
92 char *attributes_file;
93 int apply_sparse_checkout;
94 int trust_ctime;
95 + int check_stat;
96
97 /* section "branch" config values */
98 enum branch_track branch_track;
@@ -162,7 +163,6 @@ extern char *git_work_tree_cfg;
163
164 /* Environment bits from configuration mechanism */
165 extern int trust_executable_bit;
165 -extern int check_stat;
166 extern int has_symlinks;
167 extern int minimum_abbrev, default_abbrev;
168 extern int ignore_case;
statinfo.c
+5 -5
@@ -68,19 +68,19 @@ int match_stat_data(const struct stat_data *sd, struct stat *st)
68
69 if (sd->sd_mtime.sec != (unsigned int)st->st_mtime)
70 changed |= MTIME_CHANGED;
71 - if (cfg->trust_ctime && check_stat &&
71 + if (cfg->trust_ctime && cfg->check_stat &&
72 sd->sd_ctime.sec != (unsigned int)st->st_ctime)
73 changed |= CTIME_CHANGED;
74
75 #ifdef USE_NSEC
76 - if (check_stat && sd->sd_mtime.nsec != ST_MTIME_NSEC(*st))
76 + if (cfg->check_stat && sd->sd_mtime.nsec != ST_MTIME_NSEC(*st))
77 changed |= MTIME_CHANGED;
78 - if (cfg->trust_ctime && check_stat &&
78 + if (cfg->trust_ctime && cfg->check_stat &&
79 sd->sd_ctime.nsec != ST_CTIME_NSEC(*st))
80 changed |= CTIME_CHANGED;
81 #endif
82
83 - if (check_stat) {
83 + if (cfg->check_stat) {
84 if (sd->sd_uid != (unsigned int) st->st_uid ||
85 sd->sd_gid != (unsigned int) st->st_gid)
86 changed |= OWNER_CHANGED;
@@ -94,7 +94,7 @@ int match_stat_data(const struct stat_data *sd, struct stat *st)
94 * clients will have different views of what "device"
95 * the filesystem is on
96 */
97 - if (check_stat && sd->sd_dev != (unsigned int) st->st_dev)
97 + if (cfg->check_stat && sd->sd_dev != (unsigned int) st->st_dev)
98 changed |= INODE_CHANGED;
99 #endif
100