@@ -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 ,
@@ -399,12 +400,14 @@ static int set_config(struct repository *repo,
399400}
400401
401402static enum sparse_checkout_mode update_cone_mode (int * cone_mode ) {
403+ struct repo_config_values * cfg = repo_config_values (the_repository );
404+
402405 /* If not specified, use previous definition of cone mode */
403- if (* cone_mode == -1 && core_apply_sparse_checkout )
406+ if (* cone_mode == -1 && cfg -> apply_sparse_checkout )
404407 * cone_mode = core_sparse_checkout_cone ;
405408
406409 /* Set cone/non-cone mode appropriately */
407- core_apply_sparse_checkout = 1 ;
410+ cfg -> apply_sparse_checkout = 1 ;
408411 if (* cone_mode == 1 || * cone_mode == -1 ) {
409412 core_sparse_checkout_cone = 1 ;
410413 return MODE_CONE_PATTERNS ;
@@ -416,9 +419,10 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
416419static int update_modes (struct repository * repo , int * cone_mode , int * sparse_index )
417420{
418421 int mode , record_mode ;
422+ struct repo_config_values * cfg = repo_config_values (the_repository );
419423
420424 /* Determine if we need to record the mode; ensure sparse checkout on */
421- record_mode = (* cone_mode != -1 ) || !core_apply_sparse_checkout ;
425+ record_mode = (* cone_mode != -1 ) || !cfg -> apply_sparse_checkout ;
422426
423427 mode = update_cone_mode (cone_mode );
424428 if (record_mode && set_config (repo , mode ))
@@ -684,6 +688,7 @@ static int modify_pattern_list(struct repository *repo,
684688 int result ;
685689 int changed_config = 0 ;
686690 struct pattern_list * pl = xcalloc (1 , sizeof (* pl ));
691+ struct repo_config_values * cfg = repo_config_values (the_repository );
687692
688693 switch (m ) {
689694 case ADD :
@@ -699,9 +704,9 @@ static int modify_pattern_list(struct repository *repo,
699704 break ;
700705 }
701706
702- if (!core_apply_sparse_checkout ) {
707+ if (!cfg -> apply_sparse_checkout ) {
703708 set_config (repo , MODE_ALL_PATTERNS );
704- core_apply_sparse_checkout = 1 ;
709+ cfg -> apply_sparse_checkout = 1 ;
705710 changed_config = 1 ;
706711 }
707712
@@ -796,9 +801,10 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
796801 };
797802 struct strvec patterns = STRVEC_INIT ;
798803 int ret ;
804+ struct repo_config_values * cfg = repo_config_values (the_repository );
799805
800806 setup_work_tree ();
801- if (!core_apply_sparse_checkout )
807+ if (!cfg -> apply_sparse_checkout )
802808 die (_ ("no sparse-checkout to add to" ));
803809
804810 repo_read_index (repo );
@@ -905,9 +911,10 @@ static int sparse_checkout_reapply(int argc, const char **argv,
905911 N_ ("toggle the use of a sparse index" )),
906912 OPT_END (),
907913 };
914+ struct repo_config_values * cfg = repo_config_values (the_repository );
908915
909916 setup_work_tree ();
910- if (!core_apply_sparse_checkout )
917+ if (!cfg -> apply_sparse_checkout )
911918 die (_ ("must be in a sparse-checkout to reapply sparsity patterns" ));
912919
913920 reapply_opts .cone_mode = -1 ;
@@ -960,6 +967,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
960967 size_t worktree_len ;
961968 int force = 0 , dry_run = 0 , verbose = 0 ;
962969 int require_force = 1 ;
970+ struct repo_config_values * cfg = repo_config_values (the_repository );
963971
964972 struct option builtin_sparse_checkout_clean_options [] = {
965973 OPT__DRY_RUN (& dry_run , N_ ("dry run" )),
@@ -969,7 +977,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
969977 };
970978
971979 setup_work_tree ();
972- if (!core_apply_sparse_checkout )
980+ if (!cfg -> apply_sparse_checkout )
973981 die (_ ("must be in a sparse-checkout to clean directories" ));
974982 if (!core_sparse_checkout_cone )
975983 die (_ ("must be in a cone-mode sparse-checkout to clean directories" ));
@@ -1033,9 +1041,10 @@ static int sparse_checkout_disable(int argc, const char **argv,
10331041 OPT_END (),
10341042 };
10351043 struct pattern_list pl ;
1044+ struct repo_config_values * cfg = repo_config_values (the_repository );
10361045
10371046 /*
1038- * We do not exit early if !core_apply_sparse_checkout ; due to the
1047+ * We do not exit early if !repo->config_values.apply_sparse_checkout ; due to the
10391048 * ability for users to manually muck things up between
10401049 * direct editing of .git/info/sparse-checkout
10411050 * running read-tree -m u HEAD or update-index --skip-worktree
@@ -1061,7 +1070,7 @@ static int sparse_checkout_disable(int argc, const char **argv,
10611070 hashmap_init (& pl .recursive_hashmap , pl_hashmap_cmp , NULL , 0 );
10621071 hashmap_init (& pl .parent_hashmap , pl_hashmap_cmp , NULL , 0 );
10631072 pl .use_cone_patterns = 0 ;
1064- core_apply_sparse_checkout = 1 ;
1073+ cfg -> apply_sparse_checkout = 1 ;
10651074
10661075 add_pattern ("/*" , empty_base , 0 , & pl , 0 );
10671076
0 commit comments