From: Olamide Caleb Bello Date: Thu, 23 Apr 2026 16:54:31 +0000 (+0100) Subject: env: move "sparse_expect_files_outside_of_patterns" into `repo_config_values` X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=611d684e644f60c4213e9eea7244bd31064c01a7;p=thirdparty%2Fgit.git env: move "sparse_expect_files_outside_of_patterns" into `repo_config_values` 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 Mentored-by: Usman Akinyemi Signed-off-by: Olamide Caleb Bello Signed-off-by: Junio C Hamano --- 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)) {