@@ -442,7 +442,7 @@ static int module_name(int argc, const char **argv, const char *prefix)
442442}
443443
444444static int clone_submodule (const char * path , const char * gitdir , const char * url ,
445- const char * depth , const char * reference , int quiet )
445+ const char * depth , struct string_list * reference , int quiet )
446446{
447447 struct child_process cp ;
448448 child_process_init (& cp );
@@ -453,8 +453,12 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
453453 argv_array_push (& cp .args , "--quiet" );
454454 if (depth && * depth )
455455 argv_array_pushl (& cp .args , "--depth" , depth , NULL );
456- if (reference && * reference )
457- argv_array_pushl (& cp .args , "--reference" , reference , NULL );
456+ if (reference -> nr ) {
457+ struct string_list_item * item ;
458+ for_each_string_list_item (item , reference )
459+ argv_array_pushl (& cp .args , "--reference" ,
460+ item -> string , NULL );
461+ }
458462 if (gitdir && * gitdir )
459463 argv_array_pushl (& cp .args , "--separate-git-dir" , gitdir , NULL );
460464
@@ -470,13 +474,13 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
470474
471475static int module_clone (int argc , const char * * argv , const char * prefix )
472476{
473- const char * name = NULL , * url = NULL ;
474- const char * reference = NULL , * depth = NULL ;
477+ const char * name = NULL , * url = NULL , * depth = NULL ;
475478 int quiet = 0 ;
476479 FILE * submodule_dot_git ;
477480 char * p , * path = NULL , * sm_gitdir ;
478481 struct strbuf rel_path = STRBUF_INIT ;
479482 struct strbuf sb = STRBUF_INIT ;
483+ struct string_list reference = STRING_LIST_INIT_NODUP ;
480484
481485 struct option module_clone_options [] = {
482486 OPT_STRING (0 , "prefix" , & prefix ,
@@ -491,8 +495,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
491495 OPT_STRING (0 , "url" , & url ,
492496 N_ ("string" ),
493497 N_ ("url where to clone the submodule from" )),
494- OPT_STRING (0 , "reference" , & reference ,
495- N_ ("string " ),
498+ OPT_STRING_LIST (0 , "reference" , & reference ,
499+ N_ ("repo " ),
496500 N_ ("reference repository" )),
497501 OPT_STRING (0 , "depth" , & depth ,
498502 N_ ("string" ),
@@ -528,7 +532,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
528532 if (!file_exists (sm_gitdir )) {
529533 if (safe_create_leading_directories_const (sm_gitdir ) < 0 )
530534 die (_ ("could not create directory '%s'" ), sm_gitdir );
531- if (clone_submodule (path , sm_gitdir , url , depth , reference , quiet ))
535+ if (clone_submodule (path , sm_gitdir , url , depth , & reference , quiet ))
532536 die (_ ("clone of '%s' into submodule path '%s' failed" ),
533537 url , path );
534538 } else {
0 commit comments