@@ -61,9 +61,10 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
6161 struct pattern_list pl ;
6262 char * sparse_filename ;
6363 int res ;
64+ struct repo_config_values * cfg = repo_config_values (the_repository );
6465
6566 setup_work_tree ();
66- if (!core_apply_sparse_checkout )
67+ if (!cfg -> apply_sparse_checkout )
6768 die (_ ("this worktree is not sparse" ));
6869
6970 argc = parse_options (argc , argv , prefix ,
@@ -398,12 +399,14 @@ static int set_config(struct repository *repo,
398399}
399400
400401static enum sparse_checkout_mode update_cone_mode (int * cone_mode ) {
402+ struct repo_config_values * cfg = repo_config_values (the_repository );
403+
401404 /* If not specified, use previous definition of cone mode */
402- if (* cone_mode == -1 && core_apply_sparse_checkout )
405+ if (* cone_mode == -1 && cfg -> apply_sparse_checkout )
403406 * cone_mode = core_sparse_checkout_cone ;
404407
405408 /* Set cone/non-cone mode appropriately */
406- core_apply_sparse_checkout = 1 ;
409+ cfg -> apply_sparse_checkout = 1 ;
407410 if (* cone_mode == 1 || * cone_mode == -1 ) {
408411 core_sparse_checkout_cone = 1 ;
409412 return MODE_CONE_PATTERNS ;
@@ -415,9 +418,10 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
415418static int update_modes (struct repository * repo , int * cone_mode , int * sparse_index )
416419{
417420 int mode , record_mode ;
421+ struct repo_config_values * cfg = repo_config_values (the_repository );
418422
419423 /* Determine if we need to record the mode; ensure sparse checkout on */
420- record_mode = (* cone_mode != -1 ) || !core_apply_sparse_checkout ;
424+ record_mode = (* cone_mode != -1 ) || !cfg -> apply_sparse_checkout ;
421425
422426 mode = update_cone_mode (cone_mode );
423427 if (record_mode && set_config (repo , mode ))
@@ -683,6 +687,7 @@ static int modify_pattern_list(struct repository *repo,
683687 int result ;
684688 int changed_config = 0 ;
685689 struct pattern_list * pl = xcalloc (1 , sizeof (* pl ));
690+ struct repo_config_values * cfg = repo_config_values (the_repository );
686691
687692 switch (m ) {
688693 case ADD :
@@ -698,9 +703,9 @@ static int modify_pattern_list(struct repository *repo,
698703 break ;
699704 }
700705
701- if (!core_apply_sparse_checkout ) {
706+ if (!cfg -> apply_sparse_checkout ) {
702707 set_config (repo , MODE_ALL_PATTERNS );
703- core_apply_sparse_checkout = 1 ;
708+ cfg -> apply_sparse_checkout = 1 ;
704709 changed_config = 1 ;
705710 }
706711
@@ -795,9 +800,10 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
795800 };
796801 struct strvec patterns = STRVEC_INIT ;
797802 int ret ;
803+ struct repo_config_values * cfg = repo_config_values (the_repository );
798804
799805 setup_work_tree ();
800- if (!core_apply_sparse_checkout )
806+ if (!cfg -> apply_sparse_checkout )
801807 die (_ ("no sparse-checkout to add to" ));
802808
803809 repo_read_index (repo );
@@ -904,9 +910,10 @@ static int sparse_checkout_reapply(int argc, const char **argv,
904910 N_ ("toggle the use of a sparse index" )),
905911 OPT_END (),
906912 };
913+ struct repo_config_values * cfg = repo_config_values (the_repository );
907914
908915 setup_work_tree ();
909- if (!core_apply_sparse_checkout )
916+ if (!cfg -> apply_sparse_checkout )
910917 die (_ ("must be in a sparse-checkout to reapply sparsity patterns" ));
911918
912919 reapply_opts .cone_mode = -1 ;
@@ -959,6 +966,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
959966 size_t worktree_len ;
960967 int force = 0 , dry_run = 0 , verbose = 0 ;
961968 int require_force = 1 ;
969+ struct repo_config_values * cfg = repo_config_values (the_repository );
962970
963971 struct option builtin_sparse_checkout_clean_options [] = {
964972 OPT__DRY_RUN (& dry_run , N_ ("dry run" )),
@@ -968,7 +976,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
968976 };
969977
970978 setup_work_tree ();
971- if (!core_apply_sparse_checkout )
979+ if (!cfg -> apply_sparse_checkout )
972980 die (_ ("must be in a sparse-checkout to clean directories" ));
973981 if (!core_sparse_checkout_cone )
974982 die (_ ("must be in a cone-mode sparse-checkout to clean directories" ));
@@ -1032,9 +1040,10 @@ static int sparse_checkout_disable(int argc, const char **argv,
10321040 OPT_END (),
10331041 };
10341042 struct pattern_list pl ;
1043+ struct repo_config_values * cfg = repo_config_values (the_repository );
10351044
10361045 /*
1037- * We do not exit early if !core_apply_sparse_checkout ; due to the
1046+ * We do not exit early if !repo->config_values.apply_sparse_checkout ; due to the
10381047 * ability for users to manually muck things up between
10391048 * direct editing of .git/info/sparse-checkout
10401049 * running read-tree -m u HEAD or update-index --skip-worktree
@@ -1060,7 +1069,7 @@ static int sparse_checkout_disable(int argc, const char **argv,
10601069 hashmap_init (& pl .recursive_hashmap , pl_hashmap_cmp , NULL , 0 );
10611070 hashmap_init (& pl .parent_hashmap , pl_hashmap_cmp , NULL , 0 );
10621071 pl .use_cone_patterns = 0 ;
1063- core_apply_sparse_checkout = 1 ;
1072+ cfg -> apply_sparse_checkout = 1 ;
10641073
10651074 add_pattern ("/*" , empty_base , 0 , & pl , 0 );
10661075
0 commit comments