]> git.ipfire.org Git - thirdparty/git.git/commitdiff
environment: move "check_stat" into `struct repo_config_values`
authorOlamide Caleb Bello <belkid98@gmail.com>
Thu, 23 Apr 2026 16:54:26 +0000 (17:54 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 25 Apr 2026 10:35:41 +0000 (19:35 +0900)
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>
entry.c
environment.c
environment.h
statinfo.c

diff --git a/entry.c b/entry.c
index 7817aee362ed9e7e14e3a2b92c9cc0ab5f013673..c55e867d8a2bca5f2af8e4fd6be6ee41928c60a9 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -443,7 +443,8 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen)
 static void mark_colliding_entries(const struct checkout *state,
                                   struct cache_entry *ce, struct stat *st)
 {
-       int trust_ino = check_stat;
+       struct repo_config_values *cfg = repo_config_values(the_repository);
+       int trust_ino = cfg->check_stat;
 
 #if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)
        trust_ino = 0;
index 0a9067729e5025c9591d48e7a8fe7dfd5421913b..8542ac31413d5ba6bb0a385a39d183ed360c3bb5 100644 (file)
@@ -42,7 +42,6 @@ static int pack_compression_seen;
 static int zlib_compression_seen;
 
 int trust_executable_bit = 1;
-int check_stat = 1;
 int has_symlinks = 1;
 int minimum_abbrev = 4, default_abbrev = -1;
 int ignore_case;
@@ -315,9 +314,9 @@ int git_default_core_config(const char *var, const char *value,
                if (!value)
                        return config_error_nonbool(var);
                if (!strcasecmp(value, "default"))
-                       check_stat = 1;
+                       cfg->check_stat = 1;
                else if (!strcasecmp(value, "minimal"))
-                       check_stat = 0;
+                       cfg->check_stat = 0;
                else
                        return error(_("invalid value for '%s': '%s'"),
                                     var, value);
@@ -721,4 +720,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
        cfg->apply_sparse_checkout = 0;
        cfg->branch_track = BRANCH_TRACK_REMOTE;
        cfg->trust_ctime = 1;
+       cfg->check_stat = 1;
 }
index 64d537686eed17dc962773fd8f8aaf24f764b2ae..1d3e2e4f230a15fa249c8f240ac9ae1c7327431f 100644 (file)
@@ -92,6 +92,7 @@ struct repo_config_values {
        char *attributes_file;
        int apply_sparse_checkout;
        int trust_ctime;
+       int check_stat;
 
        /* section "branch" config values */
        enum branch_track branch_track;
@@ -162,7 +163,6 @@ extern char *git_work_tree_cfg;
 
 /* Environment bits from configuration mechanism */
 extern int trust_executable_bit;
-extern int check_stat;
 extern int has_symlinks;
 extern int minimum_abbrev, default_abbrev;
 extern int ignore_case;
index 4fc12053f40b20727cb97e15dac77a0bd30055f2..5e00af127d657de1fffd3baab508eec93c5f5c24 100644 (file)
@@ -68,19 +68,19 @@ int match_stat_data(const struct stat_data *sd, struct stat *st)
 
        if (sd->sd_mtime.sec != (unsigned int)st->st_mtime)
                changed |= MTIME_CHANGED;
-       if (cfg->trust_ctime && check_stat &&
+       if (cfg->trust_ctime && cfg->check_stat &&
            sd->sd_ctime.sec != (unsigned int)st->st_ctime)
                changed |= CTIME_CHANGED;
 
 #ifdef USE_NSEC
-       if (check_stat && sd->sd_mtime.nsec != ST_MTIME_NSEC(*st))
+       if (cfg->check_stat && sd->sd_mtime.nsec != ST_MTIME_NSEC(*st))
                changed |= MTIME_CHANGED;
-       if (cfg->trust_ctime && check_stat &&
+       if (cfg->trust_ctime && cfg->check_stat &&
            sd->sd_ctime.nsec != ST_CTIME_NSEC(*st))
                changed |= CTIME_CHANGED;
 #endif
 
-       if (check_stat) {
+       if (cfg->check_stat) {
                if (sd->sd_uid != (unsigned int) st->st_uid ||
                        sd->sd_gid != (unsigned int) st->st_gid)
                        changed |= OWNER_CHANGED;
@@ -94,7 +94,7 @@ int match_stat_data(const struct stat_data *sd, struct stat *st)
         * clients will have different views of what "device"
         * the filesystem is on
         */
-       if (check_stat && sd->sd_dev != (unsigned int) st->st_dev)
+       if (cfg->check_stat && sd->sd_dev != (unsigned int) st->st_dev)
                        changed |= INODE_CHANGED;
 #endif