Skip to content

Commit 66edc90

Browse files
committed
environment: move "sparse_expect_files_outside_of_patterns" into struct repo_config_values
The `sparse_expect_files_outside_of_patterns` variable was previously a global integer and uninitialized by default, which makes it shared across repository instances within a single process. Move it into `repo_config_values` and initialize it to 0 by default. 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>
1 parent 0b141c6 commit 66edc90

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

environment.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
7070
#endif
7171
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
7272
int grafts_keep_true_parents;
73-
int sparse_expect_files_outside_of_patterns;
7473
unsigned long pack_size_limit_cfg;
7574

7675
#ifndef PROTECT_HFS_DEFAULT
@@ -550,8 +549,10 @@ int git_default_core_config(const char *var, const char *value,
550549

551550
static int git_default_sparse_config(const char *var, const char *value)
552551
{
552+
struct repo_config_values *cfg = repo_config_values(the_repository);
553+
553554
if (!strcmp(var, "sparse.expectfilesoutsideofpatterns")) {
554-
sparse_expect_files_outside_of_patterns = git_config_bool(var, value);
555+
cfg->sparse_expect_files_outside_of_patterns = git_config_bool(var, value);
555556
return 0;
556557
}
557558

@@ -742,4 +743,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
742743
cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
743744
cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
744745
cfg->core_sparse_checkout_cone = 0;
746+
cfg->sparse_expect_files_outside_of_patterns = 0;
745747
}

environment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ struct repo_config_values {
9797
int precomposed_unicode;
9898
int core_sparse_checkout_cone;
9999

100+
/* section "sparse" config values */
101+
int sparse_expect_files_outside_of_patterns;
102+
100103
/* section "branch" config values */
101104
enum branch_track branch_track;
102105
};

sparse-index.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,9 @@ static void clear_skip_worktree_from_present_files_full(struct index_state *ista
673673
void clear_skip_worktree_from_present_files(struct index_state *istate)
674674
{
675675
struct repo_config_values *cfg = repo_config_values(the_repository);
676+
676677
if (!cfg->apply_sparse_checkout ||
677-
sparse_expect_files_outside_of_patterns)
678+
cfg->sparse_expect_files_outside_of_patterns)
678679
return;
679680

680681
if (clear_skip_worktree_from_present_files_sparse(istate)) {

0 commit comments

Comments
 (0)