@@ -28,8 +28,14 @@ enum {
2828 TAGS_SET = 2
2929};
3030
31+ enum {
32+ RECURSE_SUBMODULES_OFF = 0 ,
33+ RECURSE_SUBMODULES_DEFAULT = 1 ,
34+ RECURSE_SUBMODULES_ON = 2
35+ };
36+
3137static int all , append , dry_run , force , keep , multiple , prune , update_head_ok , verbosity ;
32- static int progress , recurse_submodules ;
38+ static int progress , recurse_submodules = RECURSE_SUBMODULES_DEFAULT ;
3339static int tags = TAGS_DEFAULT ;
3440static const char * depth ;
3541static const char * upload_pack ;
@@ -55,8 +61,9 @@ static struct option builtin_fetch_options[] = {
5561 "do not fetch all tags (--no-tags)" , TAGS_UNSET ),
5662 OPT_BOOLEAN ('p' , "prune" , & prune ,
5763 "prune tracking branches no longer on remote" ),
58- OPT_BOOLEAN (0 , "recurse-submodules" , & recurse_submodules ,
59- "control recursive fetching of submodules" ),
64+ OPT_SET_INT (0 , "recurse-submodules" , & recurse_submodules ,
65+ "control recursive fetching of submodules" ,
66+ RECURSE_SUBMODULES_ON ),
6067 OPT_BOOLEAN (0 , "dry-run" , & dry_run ,
6168 "dry run" ),
6269 OPT_BOOLEAN ('k' , "keep" , & keep , "keep downloaded pack" ),
@@ -795,7 +802,7 @@ static void add_options_to_argv(int *argc, const char **argv)
795802 argv [(* argc )++ ] = "--force" ;
796803 if (keep )
797804 argv [(* argc )++ ] = "--keep" ;
798- if (recurse_submodules )
805+ if (recurse_submodules == RECURSE_SUBMODULES_ON )
799806 argv [(* argc )++ ] = "--recurse-submodules" ;
800807 if (verbosity >= 2 )
801808 argv [(* argc )++ ] = "-v" ;
@@ -933,14 +940,18 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
933940 }
934941 }
935942
936- if (!result && recurse_submodules ) {
943+ if (!result && ( recurse_submodules != RECURSE_SUBMODULES_OFF ) ) {
937944 const char * options [10 ];
938945 int num_options = 0 ;
946+ /* Set recursion as default when we already are recursing */
947+ if (submodule_prefix [0 ])
948+ set_config_fetch_recurse_submodules (1 );
939949 gitmodules_config ();
940950 git_config (submodule_config , NULL );
941951 add_options_to_argv (& num_options , options );
942952 result = fetch_populated_submodules (num_options , options ,
943953 submodule_prefix ,
954+ recurse_submodules == RECURSE_SUBMODULES_ON ,
944955 verbosity < 0 );
945956 }
946957
0 commit comments