Git development
 help / color / mirror / Atom feed
From: Olamide Caleb Bello <belkid98@gmail.com>
To: git@vger.kernel.org
Cc: phillip.wood123@gmail.com, gitster@pobox.com,
	christian.couder@gmail.com, usmanakinyemi202@gmail.com,
	kaartic.sivaraam@gmail.com, me@ttaylorr.com,
	Olamide Caleb Bello <belkid98@gmail.com>
Subject: [PATCH v3 7/8] env: move "sparse_expect_files_outside_of_patterns" into `repo_config_values`
Date: Thu, 23 Apr 2026 17:54:31 +0100	[thread overview]
Message-ID: <20260423165432.143598-8-belkid98@gmail.com> (raw)
In-Reply-To: <20260423165432.143598-1-belkid98@gmail.com>

The `core.sparseCheckoutExpectFilesOutsideOfPatterns` configuration was
previously stored in a global `int` variable, making it shared across
repository instances and risking cross‑repository state leakage.

Store it instead in `repo_config_values`, where eagerly‑parsed
repository configuration lives. This option is parsed eagerly because
it controls how sparse‑checkout paths are interpreted – a fundamental
behavior that many commands rely on; a lazy parse could cause
inconsistent sparse‑checkout handling and complicate libification.
This preserves the existing behavior while tying the value to the
repository from which it was read, 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>
---
 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


  parent reply	other threads:[~2026-04-23 16:55 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 12:37 [PATCH v2 0/8] repo_config_values: migrate more globals Olamide Caleb Bello
2026-03-24 12:37 ` [PATCH v2 1/8] environment: move "trust_ctime" into `struct repo_config_values` Olamide Caleb Bello
2026-04-14  8:52   ` Karthik Nayak
2026-04-14  9:35     ` Phillip Wood
2026-04-14 17:15       ` Junio C Hamano
2026-04-15 11:16       ` Karthik Nayak
2026-04-15 15:49         ` Junio C Hamano
2026-04-15 19:09           ` Karthik Nayak
2026-03-24 12:37 ` [PATCH v2 2/8] environment: move "check_stat" " Olamide Caleb Bello
2026-04-14  8:55   ` Karthik Nayak
2026-03-24 12:37 ` [PATCH v2 3/8] environment: move `zlib_compression_level` into repo_config_values Olamide Caleb Bello
2026-04-14  8:58   ` Karthik Nayak
2026-04-14 14:32     ` Bello Olamide
2026-03-24 12:37 ` [PATCH v2 4/8] environment: move "pack_compression_level" into `struct repo_config_values` Olamide Caleb Bello
2026-03-24 12:37 ` [PATCH v2 5/8] environment: move "precomposed_unicode" " Olamide Caleb Bello
2026-04-14  9:07   ` Karthik Nayak
2026-03-24 12:37 ` [PATCH v2 6/8] env: move "core_sparse_checkout_cone" " Olamide Caleb Bello
2026-03-24 12:37 ` [PATCH v2 7/8] env: put "sparse_expect_files_outside_of_patterns" in `repo_config_values` Olamide Caleb Bello
2026-03-24 12:37 ` [PATCH v2 8/8] env: move "warn_on_object_refname_ambiguity" into `repo_config_values` Olamide Caleb Bello
2026-04-14  9:10 ` [PATCH v2 0/8] repo_config_values: migrate more globals Karthik Nayak
2026-04-14 14:26   ` Bello Olamide
2026-04-23 16:08   ` [PATCH v3 " Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 1/8] Revert "compat/posix: introduce writev(3p) wrapper" Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 2/8] rust: we are way beyond 2.53 Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 3/8] doc: am: revert Message-ID trailer claim Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 4/8] doc: am: correct to full --no-message-id Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 5/8] CI: bump actions/checkout from 4 to 5 for rust-analysis job Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 6/8] gitglossary: fix indentation of sub-lists Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 7/8] Hopefully the final tweak before -rc2 Olamide Caleb Bello
2026-04-23 16:08     ` [PATCH v3 8/8] Git 2.54-rc2 Olamide Caleb Bello
2026-04-23 16:37     ` [PATCH v3 0/8] repo_config_values: migrate more globals Bello Olamide
2026-04-23 16:54   ` [PATCH v3 0/8] environment: move core config globals into repo_config_values Olamide Caleb Bello
2026-04-23 16:54     ` [PATCH v3 1/8] environment: move "trust_ctime" into `struct repo_config_values` Olamide Caleb Bello
2026-04-23 16:54     ` [PATCH v3 2/8] environment: move "check_stat" " Olamide Caleb Bello
2026-04-23 16:54     ` [PATCH v3 3/8] environment: move `zlib_compression_level` " Olamide Caleb Bello
2026-04-23 16:54     ` [PATCH v3 4/8] environment: move "pack_compression_level" " Olamide Caleb Bello
2026-04-23 16:54     ` [PATCH v3 5/8] environment: move "precomposed_unicode" " Olamide Caleb Bello
2026-05-15 17:15       ` Tian Yuchen
2026-04-23 16:54     ` [PATCH v3 6/8] env: move "core_sparse_checkout_cone" " Olamide Caleb Bello
2026-04-23 16:54     ` Olamide Caleb Bello [this message]
2026-04-23 16:54     ` [PATCH v3 8/8] env: move "warn_on_object_refname_ambiguity" " Olamide Caleb Bello
2026-04-26  0:01     ` [PATCH v3 0/8] environment: move core config globals into repo_config_values Junio C Hamano
2026-04-26  0:31       ` Bello Olamide
2026-05-11  2:56         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260423165432.143598-8-belkid98@gmail.com \
    --to=belkid98@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=phillip.wood123@gmail.com \
    --cc=usmanakinyemi202@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox