@@ -1056,7 +1056,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
10561056}
10571057
10581058static int clone_submodule (const char * path , const char * gitdir , const char * url ,
1059- const char * depth , struct string_list * reference ,
1059+ const char * depth , struct string_list * reference , int dissociate ,
10601060 int quiet , int progress )
10611061{
10621062 struct child_process cp = CHILD_PROCESS_INIT ;
@@ -1075,6 +1075,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
10751075 argv_array_pushl (& cp .args , "--reference" ,
10761076 item -> string , NULL );
10771077 }
1078+ if (dissociate )
1079+ argv_array_push (& cp .args , "--dissociate" );
10781080 if (gitdir && * gitdir )
10791081 argv_array_pushl (& cp .args , "--separate-git-dir" , gitdir , NULL );
10801082
@@ -1190,6 +1192,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
11901192 char * p , * path = NULL , * sm_gitdir ;
11911193 struct strbuf sb = STRBUF_INIT ;
11921194 struct string_list reference = STRING_LIST_INIT_NODUP ;
1195+ int dissociate = 0 ;
11931196 char * sm_alternate = NULL , * error_strategy = NULL ;
11941197
11951198 struct option module_clone_options [] = {
@@ -1208,6 +1211,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
12081211 OPT_STRING_LIST (0 , "reference" , & reference ,
12091212 N_ ("repo" ),
12101213 N_ ("reference repository" )),
1214+ OPT_BOOL (0 , "dissociate" , & dissociate ,
1215+ N_ ("use --reference only while cloning" )),
12111216 OPT_STRING (0 , "depth" , & depth ,
12121217 N_ ("string" ),
12131218 N_ ("depth for shallow clones" )),
@@ -1247,7 +1252,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
12471252
12481253 prepare_possible_alternates (name , & reference );
12491254
1250- if (clone_submodule (path , sm_gitdir , url , depth , & reference ,
1255+ if (clone_submodule (path , sm_gitdir , url , depth , & reference , dissociate ,
12511256 quiet , progress ))
12521257 die (_ ("clone of '%s' into submodule path '%s' failed" ),
12531258 url , path );
@@ -1300,6 +1305,7 @@ struct submodule_update_clone {
13001305 int quiet ;
13011306 int recommend_shallow ;
13021307 struct string_list references ;
1308+ int dissociate ;
13031309 const char * depth ;
13041310 const char * recursive_prefix ;
13051311 const char * prefix ;
@@ -1315,7 +1321,7 @@ struct submodule_update_clone {
13151321 int failed_clones_nr , failed_clones_alloc ;
13161322};
13171323#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
1318- SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \
1324+ SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, 0, \
13191325 NULL, NULL, NULL, \
13201326 STRING_LIST_INIT_DUP, 0, NULL, 0, 0}
13211327
@@ -1442,6 +1448,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
14421448 for_each_string_list_item (item , & suc -> references )
14431449 argv_array_pushl (& child -> args , "--reference" , item -> string , NULL );
14441450 }
1451+ if (suc -> dissociate )
1452+ argv_array_push (& child -> args , "--dissociate" );
14451453 if (suc -> depth )
14461454 argv_array_push (& child -> args , suc -> depth );
14471455
@@ -1575,6 +1583,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
15751583 N_ ("rebase, merge, checkout or none" )),
15761584 OPT_STRING_LIST (0 , "reference" , & suc .references , N_ ("repo" ),
15771585 N_ ("reference repository" )),
1586+ OPT_BOOL (0 , "dissociate" , & suc .dissociate ,
1587+ N_ ("use --reference only while cloning" )),
15781588 OPT_STRING (0 , "depth" , & suc .depth , "<depth>" ,
15791589 N_ ("Create a shallow clone truncated to the "
15801590 "specified number of revisions" )),
0 commit comments