Skip to content

Commit 05d32fd

Browse files
ayu-chgitster
authored andcommitted
environment: remove the global variable 'sparse_expect_files_outside_of_patterns'
The global variable 'sparse_expect_files_outside_of_patterns' is used in a single function named 'clear_skip_worktree_from_present_files()' in sparse-index.c. Move its declaration inside that function, removing unnecessary global state. 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 3b9232a commit 05d32fd

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
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,

sparse-index.c

Lines changed: 3 additions & 1 deletion
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"
@@ -668,6 +667,9 @@ static void clear_skip_worktree_from_present_files_full(struct index_state *ista
668667

669668
void clear_skip_worktree_from_present_files(struct index_state *istate)
670669
{
670+
int sparse_expect_files_outside_of_patterns = 0;
671+
repo_config_get_bool(istate->repo, "sparse.expectfilesoutsideofpatterns",
672+
&sparse_expect_files_outside_of_patterns);
671673
if (!istate->repo->settings.sparse_checkout ||
672674
sparse_expect_files_outside_of_patterns)
673675
return;

0 commit comments

Comments
 (0)