@@ -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 );
@@ -335,6 +335,7 @@ static int write_patterns_and_update(struct repository *repo,
335335 FILE * fp ;
336336 struct lock_file lk = LOCK_INIT ;
337337 int result ;
338+ struct repo_config_values * cfg = repo_config_values (the_repository );
338339
339340 sparse_filename = get_sparse_checkout_filename ();
340341
@@ -354,7 +355,7 @@ static int write_patterns_and_update(struct repository *repo,
354355 if (!fp )
355356 die_errno (_ ("unable to fdopen %s" ), get_lock_file_path (& lk ));
356357
357- if (core_sparse_checkout_cone )
358+ if (cfg -> core_sparse_checkout_cone )
358359 write_cone_to_file (fp , pl );
359360 else
360361 write_patterns_to_file (fp , pl );
@@ -403,15 +404,15 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
403404
404405 /* If not specified, use previous definition of cone mode */
405406 if (* cone_mode == -1 && cfg -> apply_sparse_checkout )
406- * cone_mode = core_sparse_checkout_cone ;
407+ * cone_mode = cfg -> core_sparse_checkout_cone ;
407408
408409 /* Set cone/non-cone mode appropriately */
409410 cfg -> apply_sparse_checkout = 1 ;
410411 if (* cone_mode == 1 || * cone_mode == -1 ) {
411- core_sparse_checkout_cone = 1 ;
412+ cfg -> core_sparse_checkout_cone = 1 ;
412413 return MODE_CONE_PATTERNS ;
413414 }
414- core_sparse_checkout_cone = 0 ;
415+ cfg -> core_sparse_checkout_cone = 0 ;
415416 return MODE_ALL_PATTERNS ;
416417}
417418
@@ -578,7 +579,9 @@ static void add_patterns_from_input(struct pattern_list *pl,
578579 FILE * file )
579580{
580581 int i ;
581- if (core_sparse_checkout_cone ) {
582+ struct repo_config_values * cfg = repo_config_values (the_repository );
583+
584+ if (cfg -> core_sparse_checkout_cone ) {
582585 struct strbuf line = STRBUF_INIT ;
583586
584587 hashmap_init (& pl -> recursive_hashmap , pl_hashmap_cmp , NULL , 0 );
@@ -637,13 +640,14 @@ static void add_patterns_cone_mode(int argc, const char **argv,
637640 struct pattern_entry * pe ;
638641 struct hashmap_iter iter ;
639642 struct pattern_list existing ;
643+ struct repo_config_values * cfg = repo_config_values (the_repository );
640644 char * sparse_filename = get_sparse_checkout_filename ();
641645
642646 add_patterns_from_input (pl , argc , argv ,
643647 use_stdin ? stdin : NULL );
644648
645649 memset (& existing , 0 , sizeof (existing ));
646- existing .use_cone_patterns = core_sparse_checkout_cone ;
650+ existing .use_cone_patterns = cfg -> core_sparse_checkout_cone ;
647651
648652 if (add_patterns_from_file_to_list (sparse_filename , "" , 0 ,
649653 & existing , NULL , 0 ))
@@ -691,7 +695,7 @@ static int modify_pattern_list(struct repository *repo,
691695
692696 switch (m ) {
693697 case ADD :
694- if (core_sparse_checkout_cone )
698+ if (cfg -> core_sparse_checkout_cone )
695699 add_patterns_cone_mode (args -> nr , args -> v , pl , use_stdin );
696700 else
697701 add_patterns_literal (args -> nr , args -> v , pl , use_stdin );
@@ -724,11 +728,12 @@ static void sanitize_paths(struct repository *repo,
724728 const char * prefix , int skip_checks )
725729{
726730 int i ;
731+ struct repo_config_values * cfg = repo_config_values (the_repository );
727732
728733 if (!args -> nr )
729734 return ;
730735
731- if (prefix && * prefix && core_sparse_checkout_cone ) {
736+ if (prefix && * prefix && cfg -> core_sparse_checkout_cone ) {
732737 /*
733738 * The args are not pathspecs, so unfortunately we
734739 * 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 ();
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