git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1 1/8] environment: move "trust_ctime" into `struct repo_config_values`

From
Olamide Caleb Bello <belkid98@gmail.com>
Date
Mar 10, 2026, 12:06 UTC
Message-ID
<1188d351e62718f906cb5f49a9ac344b3d88dd3f.1773127785.git.belkid98@gmail.com>
In-Reply-To
<cover.1773127785.git.belkid98@gmail.com>

The `core.trustctime` configuration is currently stored in the global variable `trust_ctime`, which makes it shared across repository instances in a single process.

Store it instead in `repo_config_values`, so the value is tied to the repository from which it was read. This preserves existing behavior while avoiding cross-repository state leakage and continues 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>
---
 environment.c | 4 ++--
 environment.h | 2 +-
 statinfo.c    | 6 ++++--
 3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/environment.c b/environment.c
index fc3ed8bb1c..0a9067729e 100644
--- a/environment.c
+++ b/environment.c
@@ -42,7 +42,6 @@ static int pack_compression_seen;
 static int zlib_compression_seen;
 
 int trust_executable_bit = 1;
-int trust_ctime = 1;
 int check_stat = 1;
 int has_symlinks = 1;
 int minimum_abbrev = 4, default_abbrev = -1;
@@ -309,7 +308,7 @@ int git_default_core_config(const char *var, const char *value,
 		return 0;
 	}
 	if (!strcmp(var, "core.trustctime")) {
-		trust_ctime = git_config_bool(var, value);
+		cfg->trust_ctime = git_config_bool(var, value);
 		return 0;
 	}
 	if (!strcmp(var, "core.checkstat")) {
@@ -721,4 +720,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
 	cfg->attributes_file = NULL;
 	cfg->apply_sparse_checkout = 0;
 	cfg->branch_track = BRANCH_TRACK_REMOTE;
+	cfg->trust_ctime = 1;
 }
diff --git a/environment.h b/environment.h
index 123a71cdc8..64d537686e 100644
--- a/environment.h
+++ b/environment.h
@@ -91,6 +91,7 @@ struct repo_config_values {
 	/* section "core" config values */
 	char *attributes_file;
 	int apply_sparse_checkout;
+	int trust_ctime;
 
 	/* section "branch" config values */
 	enum branch_track branch_track;
@@ -161,7 +162,6 @@ extern char *git_work_tree_cfg;
 
 /* Environment bits from configuration mechanism */
 extern int trust_executable_bit;
-extern int trust_ctime;
 extern int check_stat;
 extern int has_symlinks;
 extern int minimum_abbrev, default_abbrev;
diff --git a/statinfo.c b/statinfo.c
index 30a164b0e6..4fc12053f4 100644
--- a/statinfo.c
+++ b/statinfo.c
@@ -3,6 +3,7 @@
 #include "git-compat-util.h"
 #include "environment.h"
 #include "statinfo.h"
+#include "repository.h"
 
 /*
  * Munge st_size into an unsigned int.
@@ -63,17 +64,18 @@ void fake_lstat_data(const struct stat_data *sd, struct stat *st)
 int match_stat_data(const struct stat_data *sd, struct stat *st)
 {
 	int changed = 0;
+	struct repo_config_values *cfg = repo_config_values(the_repository);
 
 	if (sd->sd_mtime.sec != (unsigned int)st->st_mtime)
 		changed |= MTIME_CHANGED;
-	if (trust_ctime && check_stat &&
+	if (cfg->trust_ctime && 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))
 		changed |= MTIME_CHANGED;
-	if (trust_ctime && check_stat &&
+	if (cfg->trust_ctime && check_stat &&
 	    sd->sd_ctime.nsec != ST_CTIME_NSEC(*st))
 		changed |= CTIME_CHANGED;
 #endif
-- 
2.53.0.155.g9f36b15afa
Previous: Olamide Caleb BelloNext: Olamide Caleb Bello
Message 2 of 14 in “repo_config_values: migrate more globals”
  1. 0/8 repo_config_values: migrate more globalsOlamide Caleb Bello, Mar 10, 2026
  2. 1/8 environment: move "trust_ctime" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  3. 2/8 environment: move "check_stat" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  4. 3/8 environment: move `zlib_compression_level` into repo_config_valuesOlamide Caleb Bello, Mar 10, 2026
  5. 4/8 environment: move "pack_compression_level" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  6. 5/8 environment: move "precomposed_unicode" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  7. 6/8 env: move "core_sparse_checkout_cone" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  8. 7/8 env: put "sparse_expect_files_outside_of_patterns" in `repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  9. 8/8 env: move "warn_on_object_refname_ambiguity" into `repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  10. Christian CouderMar 10, 2026
  11. Bello OlamideMar 12, 2026
  12. Tian YuchenMar 12, 2026
  13. Bello OlamideMar 12, 2026
  14. Bello OlamideMar 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.