Skip to content

Commit f35bd74

Browse files
ayu-chgitster
authored andcommitted
environment: remove the global variable 'sparse_expect_files_outside_of_patterns'
The setting "sparse.expectFilesOutsideOfPatterns" is stored in the global variable 'sparse_expect_files_outside_of_patterns' and allows files marked with the `SKIP_WORKTREE` bit to be present in the worktree. As this setting is closely related to repository, remove the global variable and store the setting in the `struct repo_settings` along with other sparse checkout related settings. This also allows us to remove the definition '#define USE_THE_REPOSITORY_VARIABLE' from the file 'sparse-index.c'. This change is part of an ongoing effort to eliminate global variables, improve modularity and help libify the codebase. Mentored-by: Christian Couder <[email protected]> Mentored-by: Ghanshyam Thakkar <[email protected]> Signed-off-by: Ayush Chandekar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fd8bf1 commit f35bd74

File tree

6 files changed

+3
-19
lines changed

6 files changed

+3
-19
lines changed

config.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,17 +1636,6 @@ static int git_default_core_config(const char *var, const char *value,
16361636
return platform_core_config(var, value, ctx, cb);
16371637
}
16381638

1639-
static int git_default_sparse_config(const char *var, const char *value)
1640-
{
1641-
if (!strcmp(var, "sparse.expectfilesoutsideofpatterns")) {
1642-
sparse_expect_files_outside_of_patterns = git_config_bool(var, value);
1643-
return 0;
1644-
}
1645-
1646-
/* Add other config variables here and to Documentation/config/sparse.adoc. */
1647-
return 0;
1648-
}
1649-
16501639
static int git_default_i18n_config(const char *var, const char *value)
16511640
{
16521641
if (!strcmp(var, "i18n.commitencoding")) {
@@ -1808,9 +1797,6 @@ int git_default_config(const char *var, const char *value,
18081797
return 0;
18091798
}
18101799

1811-
if (starts_with(var, "sparse."))
1812-
return git_default_sparse_config(var, value);
1813-
18141800
/* Add other config variables here and to Documentation/config.adoc. */
18151801
return 0;
18161802
}

environment.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
6464
#endif
6565
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
6666
int grafts_keep_true_parents;
67-
int sparse_expect_files_outside_of_patterns;
6867
int merge_log_config = -1;
6968
int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
7069
unsigned long pack_size_limit_cfg;

environment.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ extern int precomposed_unicode;
160160
extern int protect_hfs;
161161
extern int protect_ntfs;
162162

163-
extern int sparse_expect_files_outside_of_patterns;
164-
165163
enum rebase_setup_type {
166164
AUTOREBASE_NEVER = 0,
167165
AUTOREBASE_LOCAL,

repo-settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void prepare_repo_settings(struct repository *r)
8383
repo_cfg_bool(r, "core.usereplacerefs", &r->settings.read_replace_refs, 1);
8484
repo_cfg_bool(r, "core.sparsecheckout", &r->settings.sparse_checkout, 0);
8585
repo_cfg_bool(r, "core.sparsecheckoutcone", &r->settings.sparse_checkout_cone, 0);
86+
repo_cfg_bool(r, "sparse.expectfilesoutsideofpatterns", &r->settings.sparse_expect_files_outside_of_patterns, 0);
8687

8788
/*
8889
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that

repo-settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct repo_settings {
7070

7171
int sparse_checkout;
7272
int sparse_checkout_cone;
73+
int sparse_expect_files_outside_of_patterns;
7374
};
7475
#define REPO_SETTINGS_INIT { \
7576
.shared_repository = -1, \

sparse-index.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
@@ -669,7 +668,7 @@ static void clear_skip_worktree_from_present_files_full(struct index_state *ista
669668
void clear_skip_worktree_from_present_files(struct index_state *istate)
670669
{
671670
if (!istate->repo->settings.sparse_checkout ||
672-
sparse_expect_files_outside_of_patterns)
671+
istate->repo->settings.sparse_expect_files_outside_of_patterns)
673672
return;
674673

675674
if (clear_skip_worktree_from_present_files_sparse(istate)) {

0 commit comments

Comments
 (0)