@@ -442,7 +442,7 @@ static int module_name(int argc, const char **argv, const char *prefix)
442
442
}
443
443
444
444
static 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 )
446
446
{
447
447
struct child_process cp ;
448
448
child_process_init (& cp );
@@ -453,8 +453,12 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
453
453
argv_array_push (& cp .args , "--quiet" );
454
454
if (depth && * depth )
455
455
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
+ }
458
462
if (gitdir && * gitdir )
459
463
argv_array_pushl (& cp .args , "--separate-git-dir" , gitdir , NULL );
460
464
@@ -470,13 +474,13 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
470
474
471
475
static int module_clone (int argc , const char * * argv , const char * prefix )
472
476
{
473
- const char * name = NULL , * url = NULL ;
474
- const char * reference = NULL , * depth = NULL ;
477
+ const char * name = NULL , * url = NULL , * depth = NULL ;
475
478
int quiet = 0 ;
476
479
FILE * submodule_dot_git ;
477
480
char * p , * path = NULL , * sm_gitdir ;
478
481
struct strbuf rel_path = STRBUF_INIT ;
479
482
struct strbuf sb = STRBUF_INIT ;
483
+ struct string_list reference = STRING_LIST_INIT_NODUP ;
480
484
481
485
struct option module_clone_options [] = {
482
486
OPT_STRING (0 , "prefix" , & prefix ,
@@ -491,8 +495,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
491
495
OPT_STRING (0 , "url" , & url ,
492
496
N_ ("string" ),
493
497
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 " ),
496
500
N_ ("reference repository" )),
497
501
OPT_STRING (0 , "depth" , & depth ,
498
502
N_ ("string" ),
@@ -528,7 +532,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
528
532
if (!file_exists (sm_gitdir )) {
529
533
if (safe_create_leading_directories_const (sm_gitdir ) < 0 )
530
534
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 ))
532
536
die (_ ("clone of '%s' into submodule path '%s' failed" ),
533
537
url , path );
534
538
} else {
0 commit comments