@@ -40,6 +40,7 @@ static const char * const builtin_clone_usage[] = {
4040
4141static int option_no_checkout , option_bare , option_mirror , option_single_branch = -1 ;
4242static int option_local = -1 , option_no_hardlinks , option_shared , option_recursive ;
43+ static int option_shallow_submodules = -1 ;
4344static char * option_template , * option_depth ;
4445static char * option_origin = NULL ;
4546static char * option_branch = NULL ;
@@ -92,6 +93,8 @@ static struct option builtin_clone_options[] = {
9293 N_ ("create a shallow clone of that depth" )),
9394 OPT_BOOL (0 , "single-branch" , & option_single_branch ,
9495 N_ ("clone only one branch, HEAD or --branch" )),
96+ OPT_BOOL (0 , "shallow-submodules" , & option_shallow_submodules ,
97+ N_ ("any cloned submodules will be shallow" )),
9598 OPT_STRING (0 , "separate-git-dir" , & real_git_dir , N_ ("gitdir" ),
9699 N_ ("separate git dir from working tree" )),
97100 OPT_STRING_LIST ('c' , "config" , & option_config , N_ ("key=value" ),
@@ -735,6 +738,10 @@ static int checkout(void)
735738 struct argv_array args = ARGV_ARRAY_INIT ;
736739 argv_array_pushl (& args , "submodule" , "update" , "--init" , "--recursive" , NULL );
737740
741+ if (option_shallow_submodules == 1
742+ || (option_shallow_submodules == -1 && option_depth ))
743+ argv_array_push (& args , "--depth=1" );
744+
738745 if (max_jobs != -1 )
739746 argv_array_pushf (& args , "--jobs=%d" , max_jobs );
740747
0 commit comments