git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:25 UTC

[PATCH v1 7/8] env: put "sparse_expect_files_outside_of_patterns" in `repo_config_values`

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

The `sparse_expect_files_outside_of_patterns` variable was previously a global variable, which makes it shared across repository instances within a single process.

Move it into `repo_config_values`, this makes the value tied to the repository from which it was read. This preserves existing behavior while avoiding cross-repository state leakage and is another step toward eliminating repository-dependent global 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  | 6 ++++--
 environment.h  | 5 +++--
 sparse-index.c | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/environment.c b/environment.c
index b0e873e9f5..57587ede56 100644
--- a/environment.c
+++ b/environment.c
@@ -70,7 +70,6 @@ enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
 #endif
 enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
 int grafts_keep_true_parents;
-int sparse_expect_files_outside_of_patterns;
 unsigned long pack_size_limit_cfg;
 
 #ifndef PROTECT_HFS_DEFAULT
@@ -550,8 +549,10 @@ int git_default_core_config(const char *var, const char *value,
 
 static int git_default_sparse_config(const char *var, const char *value)
 {
+	struct repo_config_values *cfg = repo_config_values(the_repository);
+
 	if (!strcmp(var, "sparse.expectfilesoutsideofpatterns")) {
-		sparse_expect_files_outside_of_patterns = git_config_bool(var, value);
+		cfg->sparse_expect_files_outside_of_patterns = git_config_bool(var, value);
 		return 0;
 	}
 
@@ -723,4 +724,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
 	cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
 	cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 	cfg->core_sparse_checkout_cone = 0;
+	cfg->sparse_expect_files_outside_of_patterns = 0;
 }
diff --git a/environment.h b/environment.h
index befad9a388..609cdaa07f 100644
--- a/environment.h
+++ b/environment.h
@@ -98,6 +98,9 @@ struct repo_config_values {
 	int precomposed_unicode;
 	int core_sparse_checkout_cone;
 
+	/* section "sparse" config values */
+	int sparse_expect_files_outside_of_patterns;
+
 	/* section "branch" config values */
 	enum branch_track branch_track;
 };
@@ -179,8 +182,6 @@ extern unsigned long pack_size_limit_cfg;
 extern int protect_hfs;
 extern int protect_ntfs;
 
-extern int sparse_expect_files_outside_of_patterns;
-
 enum rebase_setup_type {
 	AUTOREBASE_NEVER = 0,
 	AUTOREBASE_LOCAL,
diff --git a/sparse-index.c b/sparse-index.c
index 53cb8d64fc..1ed769b78d 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -675,7 +675,7 @@ void clear_skip_worktree_from_present_files(struct index_state *istate)
 	struct repo_config_values *cfg = repo_config_values(the_repository);
 
 	if (!cfg->apply_sparse_checkout ||
-	    sparse_expect_files_outside_of_patterns)
+	    cfg->sparse_expect_files_outside_of_patterns)
 		return;
 
 	if (clear_skip_worktree_from_present_files_sparse(istate)) {
-- 
2.53.0.155.g9f36b15afa
Previous: Olamide Caleb BelloNext: Olamide Caleb Bello
Message 8 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. Tian YuchenMar 12, 2026
  12. Bello OlamideMar 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.