]> git.ipfire.org Git - thirdparty/git.git/commitdiff
environment: remove the global variable 'sparse_expect_files_outside_of_patterns'
authorAyush Chandekar <ayu.chandekar@gmail.com>
Tue, 17 Jun 2025 12:06:36 +0000 (17:36 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Jun 2025 15:29:46 +0000 (08:29 -0700)
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 <christian.couder@gmail.com>
Mentored-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
environment.c
environment.h
sparse-index.c

index 707fe0707a342ab72d9efa7e0d68827a4e037751..d212329799a0bb434ab194e700b44dce2d143095 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1636,17 +1636,6 @@ static int git_default_core_config(const char *var, const char *value,
        return platform_core_config(var, value, ctx, cb);
 }
 
-static int git_default_sparse_config(const char *var, const char *value)
-{
-       if (!strcmp(var, "sparse.expectfilesoutsideofpatterns")) {
-               sparse_expect_files_outside_of_patterns = git_config_bool(var, value);
-               return 0;
-       }
-
-       /* Add other config variables here and to Documentation/config/sparse.adoc. */
-       return 0;
-}
-
 static int git_default_i18n_config(const char *var, const char *value)
 {
        if (!strcmp(var, "i18n.commitencoding")) {
@@ -1808,9 +1797,6 @@ int git_default_config(const char *var, const char *value,
                return 0;
        }
 
-       if (starts_with(var, "sparse."))
-               return git_default_sparse_config(var, value);
-
        /* Add other config variables here and to Documentation/config.adoc. */
        return 0;
 }
index 7d46b807112eb48871b9ec0c6be16da10cbfb1a7..d51e0a14aa0ee46735a48724efe979a72832d144 100644 (file)
@@ -64,7 +64,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;
 int merge_log_config = -1;
 int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 unsigned long pack_size_limit_cfg;
index 00a5b332a024e11152fd12a873a1550189cdf924..5121a28d3fbda6c30cba39f6e6d2a4ca2ceb531c 100644 (file)
@@ -160,8 +160,6 @@ extern int precomposed_unicode;
 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,
index 444da8a75304742bd757e0295dd5b0129cc6e527..5d87fc65c0ade046cabd36b59dbce1a84381b41b 100644 (file)
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -668,6 +667,9 @@ static void clear_skip_worktree_from_present_files_full(struct index_state *ista
 
 void clear_skip_worktree_from_present_files(struct index_state *istate)
 {
+       int sparse_expect_files_outside_of_patterns = 0;
+       repo_config_get_bool(istate->repo, "sparse.expectfilesoutsideofpatterns", 
+               &sparse_expect_files_outside_of_patterns);
        if (!istate->repo->settings.sparse_checkout ||
            sparse_expect_files_outside_of_patterns)
                return;