@@ -73,7 +73,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
7373
7474 memset (& pl , 0 , sizeof (pl ));
7575
76- pl .use_cone_patterns = core_sparse_checkout_cone ;
76+ pl .use_cone_patterns = cfg -> core_sparse_checkout_cone ;
7777
7878 sparse_filename = get_sparse_checkout_filename ();
7979 res = add_patterns_from_file_to_list (sparse_filename , "" , 0 , & pl , NULL , 0 );
@@ -334,6 +334,7 @@ static int write_patterns_and_update(struct repository *repo,
334334 FILE * fp ;
335335 struct lock_file lk = LOCK_INIT ;
336336 int result ;
337+ struct repo_config_values * cfg = repo_config_values (the_repository );
337338
338339 sparse_filename = get_sparse_checkout_filename ();
339340
@@ -353,7 +354,7 @@ static int write_patterns_and_update(struct repository *repo,
353354 if (!fp )
354355 die_errno (_ ("unable to fdopen %s" ), get_lock_file_path (& lk ));
355356
356- if (core_sparse_checkout_cone )
357+ if (cfg -> core_sparse_checkout_cone )
357358 write_cone_to_file (fp , pl );
358359 else
359360 write_patterns_to_file (fp , pl );
@@ -402,15 +403,15 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
402403
403404 /* If not specified, use previous definition of cone mode */
404405 if (* cone_mode == -1 && cfg -> apply_sparse_checkout )
405- * cone_mode = core_sparse_checkout_cone ;
406+ * cone_mode = cfg -> core_sparse_checkout_cone ;
406407
407408 /* Set cone/non-cone mode appropriately */
408409 cfg -> apply_sparse_checkout = 1 ;
409410 if (* cone_mode == 1 || * cone_mode == -1 ) {
410- core_sparse_checkout_cone = 1 ;
411+ cfg -> core_sparse_checkout_cone = 1 ;
411412 return MODE_CONE_PATTERNS ;
412413 }
413- core_sparse_checkout_cone = 0 ;
414+ cfg -> core_sparse_checkout_cone = 0 ;
414415 return MODE_ALL_PATTERNS ;
415416}
416417
@@ -577,7 +578,9 @@ static void add_patterns_from_input(struct pattern_list *pl,
577578 FILE * file )
578579{
579580 int i ;
580- if (core_sparse_checkout_cone ) {
581+ struct repo_config_values * cfg = repo_config_values (the_repository );
582+
583+ if (cfg -> core_sparse_checkout_cone ) {
581584 struct strbuf line = STRBUF_INIT ;
582585
583586 hashmap_init (& pl -> recursive_hashmap , pl_hashmap_cmp , NULL , 0 );
@@ -636,13 +639,14 @@ static void add_patterns_cone_mode(int argc, const char **argv,
636639 struct pattern_entry * pe ;
637640 struct hashmap_iter iter ;
638641 struct pattern_list existing ;
642+ struct repo_config_values * cfg = repo_config_values (the_repository );
639643 char * sparse_filename = get_sparse_checkout_filename ();
640644
641645 add_patterns_from_input (pl , argc , argv ,
642646 use_stdin ? stdin : NULL );
643647
644648 memset (& existing , 0 , sizeof (existing ));
645- existing .use_cone_patterns = core_sparse_checkout_cone ;
649+ existing .use_cone_patterns = cfg -> core_sparse_checkout_cone ;
646650
647651 if (add_patterns_from_file_to_list (sparse_filename , "" , 0 ,
648652 & existing , NULL , 0 ))
@@ -690,7 +694,7 @@ static int modify_pattern_list(struct repository *repo,
690694
691695 switch (m ) {
692696 case ADD :
693- if (core_sparse_checkout_cone )
697+ if (cfg -> core_sparse_checkout_cone )
694698 add_patterns_cone_mode (args -> nr , args -> v , pl , use_stdin );
695699 else
696700 add_patterns_literal (args -> nr , args -> v , pl , use_stdin );
@@ -723,11 +727,12 @@ static void sanitize_paths(struct repository *repo,
723727 const char * prefix , int skip_checks )
724728{
725729 int i ;
730+ struct repo_config_values * cfg = repo_config_values (the_repository );
726731
727732 if (!args -> nr )
728733 return ;
729734
730- if (prefix && * prefix && core_sparse_checkout_cone ) {
735+ if (prefix && * prefix && cfg -> core_sparse_checkout_cone ) {
731736 /*
732737 * The args are not pathspecs, so unfortunately we
733738 * cannot imitate how cmd_add() uses parse_pathspec().
@@ -745,10 +750,10 @@ static void sanitize_paths(struct repository *repo,
745750 if (skip_checks )
746751 return ;
747752
748- if (prefix && * prefix && !core_sparse_checkout_cone )
753+ if (prefix && * prefix && !cfg -> core_sparse_checkout_cone )
749754 die (_ ("please run from the toplevel directory in non-cone mode" ));
750755
751- if (core_sparse_checkout_cone ) {
756+ if (cfg -> core_sparse_checkout_cone ) {
752757 for (i = 0 ; i < args -> nr ; i ++ ) {
753758 if (args -> v [i ][0 ] == '/' )
754759 die (_ ("specify directories rather than patterns (no leading slash)" ));
@@ -770,7 +775,7 @@ static void sanitize_paths(struct repository *repo,
770775 if (S_ISSPARSEDIR (ce -> ce_mode ))
771776 continue ;
772777
773- if (core_sparse_checkout_cone )
778+ if (cfg -> core_sparse_checkout_cone )
774779 die (_ ("'%s' is not a directory; to treat it as a directory anyway, rerun with --skip-checks" ), args -> v [i ]);
775780 else
776781 warning (_ ("pass a leading slash before paths such as '%s' if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)." ), args -> v [i ]);
@@ -837,6 +842,7 @@ static struct sparse_checkout_set_opts {
837842static int sparse_checkout_set (int argc , const char * * argv , const char * prefix ,
838843 struct repository * repo )
839844{
845+ struct repo_config_values * cfg = repo_config_values (the_repository );
840846 int default_patterns_nr = 2 ;
841847 const char * default_patterns [] = {"/*" , "!/*/" , NULL };
842848
@@ -874,7 +880,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
874880 * non-cone mode, if nothing is specified, manually select just the
875881 * top-level directory (much as 'init' would do).
876882 */
877- if (!core_sparse_checkout_cone && !set_opts .use_stdin && argc == 0 ) {
883+ if (!cfg -> core_sparse_checkout_cone && !set_opts .use_stdin && argc == 0 ) {
878884 for (int i = 0 ; i < default_patterns_nr ; i ++ )
879885 strvec_push (& patterns , default_patterns [i ]);
880886 } else {
@@ -978,7 +984,7 @@ static int sparse_checkout_clean(int argc, const char **argv,
978984 setup_work_tree (the_repository );
979985 if (!cfg -> apply_sparse_checkout )
980986 die (_ ("must be in a sparse-checkout to clean directories" ));
981- if (!core_sparse_checkout_cone )
987+ if (!cfg -> core_sparse_checkout_cone )
982988 die (_ ("must be in a cone-mode sparse-checkout to clean directories" ));
983989
984990 argc = parse_options (argc , argv , prefix ,
@@ -1142,6 +1148,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
11421148 FILE * fp ;
11431149 int ret ;
11441150 struct pattern_list pl = {0 };
1151+ struct repo_config_values * cfg = repo_config_values (the_repository );
11451152 char * sparse_filename ;
11461153 check_rules_opts .cone_mode = -1 ;
11471154
@@ -1153,7 +1160,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
11531160 check_rules_opts .cone_mode = 1 ;
11541161
11551162 update_cone_mode (& check_rules_opts .cone_mode );
1156- pl .use_cone_patterns = core_sparse_checkout_cone ;
1163+ pl .use_cone_patterns = cfg -> core_sparse_checkout_cone ;
11571164 if (check_rules_opts .rules_file ) {
11581165 fp = xfopen (check_rules_opts .rules_file , "r" );
11591166 add_patterns_from_input (& pl , argc , argv , fp );
0 commit comments