@@ -1532,6 +1532,7 @@ struct module_clone_data {
15321532 const char * url ;
15331533 int depth ;
15341534 struct list_objects_filter_options * filter_options ;
1535+ enum ref_storage_format ref_storage_format ;
15351536 unsigned int quiet : 1 ;
15361537 unsigned int progress : 1 ;
15371538 unsigned int dissociate : 1 ;
@@ -1540,6 +1541,7 @@ struct module_clone_data {
15401541};
15411542#define MODULE_CLONE_DATA_INIT { \
15421543 .single_branch = -1, \
1544+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
15431545}
15441546
15451547struct submodule_alternate_setup {
@@ -1738,6 +1740,9 @@ static int clone_submodule(const struct module_clone_data *clone_data,
17381740 strvec_pushl (& cp .args , "--reference" ,
17391741 item -> string , NULL );
17401742 }
1743+ if (clone_data -> ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN )
1744+ strvec_pushf (& cp .args , "--ref-format=%s" ,
1745+ ref_storage_format_to_name (clone_data -> ref_storage_format ));
17411746 if (clone_data -> dissociate )
17421747 strvec_push (& cp .args , "--dissociate" );
17431748 if (sm_gitdir && * sm_gitdir )
@@ -1832,6 +1837,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
18321837 struct string_list reference = STRING_LIST_INIT_NODUP ;
18331838 struct list_objects_filter_options filter_options =
18341839 LIST_OBJECTS_FILTER_INIT ;
1840+ const char * ref_storage_format = NULL ;
18351841
18361842 struct option module_clone_options [] = {
18371843 OPT_STRING (0 , "prefix" , & clone_data .prefix ,
@@ -1849,6 +1855,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
18491855 OPT_STRING_LIST (0 , "reference" , & reference ,
18501856 N_ ("repo" ),
18511857 N_ ("reference repository" )),
1858+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
1859+ N_ ("specify the reference format to use" )),
18521860 OPT_BOOL (0 , "dissociate" , & dissociate ,
18531861 N_ ("use --reference only while cloning" )),
18541862 OPT_INTEGER (0 , "depth" , & clone_data .depth ,
@@ -1874,6 +1882,11 @@ static int module_clone(int argc, const char **argv, const char *prefix)
18741882 argc = parse_options (argc , argv , prefix , module_clone_options ,
18751883 git_submodule_helper_usage , 0 );
18761884
1885+ if (ref_storage_format ) {
1886+ clone_data .ref_storage_format = ref_storage_format_by_name (ref_storage_format );
1887+ if (clone_data .ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN )
1888+ die (_ ("unknown ref storage format '%s'" ), ref_storage_format );
1889+ }
18771890 clone_data .dissociate = !!dissociate ;
18781891 clone_data .quiet = !!quiet ;
18791892 clone_data .progress = !!progress ;
@@ -1973,6 +1986,7 @@ struct update_data {
19731986 struct submodule_update_strategy update_strategy ;
19741987 struct list_objects_filter_options * filter_options ;
19751988 struct module_list list ;
1989+ enum ref_storage_format ref_storage_format ;
19761990 int depth ;
19771991 int max_jobs ;
19781992 int single_branch ;
@@ -1996,6 +2010,7 @@ struct update_data {
19962010#define UPDATE_DATA_INIT { \
19972011 .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT, \
19982012 .list = MODULE_LIST_INIT, \
2013+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
19992014 .recommend_shallow = -1, \
20002015 .references = STRING_LIST_INIT_DUP, \
20012016 .single_branch = -1, \
@@ -2131,6 +2146,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
21312146 expand_list_objects_filter_spec (suc -> update_data -> filter_options ));
21322147 if (suc -> update_data -> require_init )
21332148 strvec_push (& child -> args , "--require-init" );
2149+ if (suc -> update_data -> ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN )
2150+ strvec_pushf (& child -> args , "--ref-format=%s" ,
2151+ ref_storage_format_to_name (suc -> update_data -> ref_storage_format ));
21342152 strvec_pushl (& child -> args , "--path" , sub -> path , NULL );
21352153 strvec_pushl (& child -> args , "--name" , sub -> name , NULL );
21362154 strvec_pushl (& child -> args , "--url" , url , NULL );
@@ -2565,6 +2583,9 @@ static void update_data_to_args(const struct update_data *update_data,
25652583 for_each_string_list_item (item , & update_data -> references )
25662584 strvec_pushl (args , "--reference" , item -> string , NULL );
25672585 }
2586+ if (update_data -> ref_storage_format != REF_STORAGE_FORMAT_UNKNOWN )
2587+ strvec_pushf (args , "--ref-format=%s" ,
2588+ ref_storage_format_to_name (update_data -> ref_storage_format ));
25682589 if (update_data -> filter_options && update_data -> filter_options -> choice )
25692590 strvec_pushf (args , "--filter=%s" ,
25702591 expand_list_objects_filter_spec (
@@ -2740,6 +2761,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
27402761 struct update_data opt = UPDATE_DATA_INIT ;
27412762 struct list_objects_filter_options filter_options =
27422763 LIST_OBJECTS_FILTER_INIT ;
2764+ const char * ref_storage_format = NULL ;
27432765 int ret ;
27442766 struct option module_update_options [] = {
27452767 OPT__SUPER_PREFIX (& opt .super_prefix ),
@@ -2763,6 +2785,8 @@ static int module_update(int argc, const char **argv, const char *prefix)
27632785 SM_UPDATE_REBASE ),
27642786 OPT_STRING_LIST (0 , "reference" , & opt .references , N_ ("repo" ),
27652787 N_ ("reference repository" )),
2788+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
2789+ N_ ("specify the reference format to use" )),
27662790 OPT_BOOL (0 , "dissociate" , & opt .dissociate ,
27672791 N_ ("use --reference only while cloning" )),
27682792 OPT_INTEGER (0 , "depth" , & opt .depth ,
@@ -2806,6 +2830,12 @@ static int module_update(int argc, const char **argv, const char *prefix)
28062830 module_update_options );
28072831 }
28082832
2833+ if (ref_storage_format ) {
2834+ opt .ref_storage_format = ref_storage_format_by_name (ref_storage_format );
2835+ if (opt .ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN )
2836+ die (_ ("unknown ref storage format '%s'" ), ref_storage_format );
2837+ }
2838+
28092839 opt .filter_options = & filter_options ;
28102840 opt .prefix = prefix ;
28112841
@@ -3101,13 +3131,17 @@ struct add_data {
31013131 const char * sm_name ;
31023132 const char * repo ;
31033133 const char * realrepo ;
3134+ enum ref_storage_format ref_storage_format ;
31043135 int depth ;
31053136 unsigned int force : 1 ;
31063137 unsigned int quiet : 1 ;
31073138 unsigned int progress : 1 ;
31083139 unsigned int dissociate : 1 ;
31093140};
3110- #define ADD_DATA_INIT { .depth = -1 }
3141+ #define ADD_DATA_INIT { \
3142+ .depth = -1, \
3143+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
3144+ }
31113145
31123146static void append_fetch_remotes (struct strbuf * msg , const char * git_dir_path )
31133147{
@@ -3201,6 +3235,7 @@ static int add_submodule(const struct add_data *add_data)
32013235
32023236 string_list_append (& reference , p )-> util = p ;
32033237 }
3238+ clone_data .ref_storage_format = add_data -> ref_storage_format ;
32043239 clone_data .dissociate = add_data -> dissociate ;
32053240 if (add_data -> depth >= 0 )
32063241 clone_data .depth = add_data -> depth ;
@@ -3366,6 +3401,7 @@ static int module_add(int argc, const char **argv, const char *prefix)
33663401{
33673402 int force = 0 , quiet = 0 , progress = 0 , dissociate = 0 ;
33683403 struct add_data add_data = ADD_DATA_INIT ;
3404+ const char * ref_storage_format = NULL ;
33693405 char * to_free = NULL ;
33703406 struct option options [] = {
33713407 OPT_STRING ('b' , "branch" , & add_data .branch , N_ ("branch" ),
@@ -3376,6 +3412,8 @@ static int module_add(int argc, const char **argv, const char *prefix)
33763412 OPT_BOOL (0 , "progress" , & progress , N_ ("force cloning progress" )),
33773413 OPT_STRING (0 , "reference" , & add_data .reference_path , N_ ("repository" ),
33783414 N_ ("reference repository" )),
3415+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
3416+ N_ ("specify the reference format to use" )),
33793417 OPT_BOOL (0 , "dissociate" , & dissociate , N_ ("borrow the objects from reference repositories" )),
33803418 OPT_STRING (0 , "name" , & add_data .sm_name , N_ ("name" ),
33813419 N_ ("sets the submodule's name to the given string "
@@ -3402,6 +3440,12 @@ static int module_add(int argc, const char **argv, const char *prefix)
34023440 if (argc == 0 || argc > 2 )
34033441 usage_with_options (usage , options );
34043442
3443+ if (ref_storage_format ) {
3444+ add_data .ref_storage_format = ref_storage_format_by_name (ref_storage_format );
3445+ if (add_data .ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN )
3446+ die (_ ("unknown ref storage format '%s'" ), ref_storage_format );
3447+ }
3448+
34053449 add_data .repo = argv [0 ];
34063450 if (argc == 1 )
34073451 add_data .sm_path = git_url_basename (add_data .repo , 0 , 0 );
0 commit comments