@@ -3128,13 +3128,17 @@ struct add_data {
31283128 const char * sm_name ;
31293129 const char * repo ;
31303130 const char * realrepo ;
3131+ enum ref_storage_format ref_storage_format ;
31313132 int depth ;
31323133 unsigned int force : 1 ;
31333134 unsigned int quiet : 1 ;
31343135 unsigned int progress : 1 ;
31353136 unsigned int dissociate : 1 ;
31363137};
3137- #define ADD_DATA_INIT { .depth = -1 }
3138+ #define ADD_DATA_INIT { \
3139+ .depth = -1, \
3140+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
3141+ }
31383142
31393143static void append_fetch_remotes (struct strbuf * msg , const char * git_dir_path )
31403144{
@@ -3228,6 +3232,7 @@ static int add_submodule(const struct add_data *add_data)
32283232
32293233 string_list_append (& reference , p )-> util = p ;
32303234 }
3235+ clone_data .ref_storage_format = add_data -> ref_storage_format ;
32313236 clone_data .dissociate = add_data -> dissociate ;
32323237 if (add_data -> depth >= 0 )
32333238 clone_data .depth = xstrfmt ("%d" , add_data -> depth );
@@ -3392,6 +3397,7 @@ static int module_add(int argc, const char **argv, const char *prefix)
33923397{
33933398 int force = 0 , quiet = 0 , progress = 0 , dissociate = 0 ;
33943399 struct add_data add_data = ADD_DATA_INIT ;
3400+ const char * ref_storage_format = NULL ;
33953401 char * to_free = NULL ;
33963402 struct option options [] = {
33973403 OPT_STRING ('b' , "branch" , & add_data .branch , N_ ("branch" ),
@@ -3402,6 +3408,8 @@ static int module_add(int argc, const char **argv, const char *prefix)
34023408 OPT_BOOL (0 , "progress" , & progress , N_ ("force cloning progress" )),
34033409 OPT_STRING (0 , "reference" , & add_data .reference_path , N_ ("repository" ),
34043410 N_ ("reference repository" )),
3411+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
3412+ N_ ("specify the reference format to use" )),
34053413 OPT_BOOL (0 , "dissociate" , & dissociate , N_ ("borrow the objects from reference repositories" )),
34063414 OPT_STRING (0 , "name" , & add_data .sm_name , N_ ("name" ),
34073415 N_ ("sets the submodule's name to the given string "
@@ -3428,6 +3436,12 @@ static int module_add(int argc, const char **argv, const char *prefix)
34283436 if (argc == 0 || argc > 2 )
34293437 usage_with_options (usage , options );
34303438
3439+ if (ref_storage_format ) {
3440+ add_data .ref_storage_format = ref_storage_format_by_name (ref_storage_format );
3441+ if (add_data .ref_storage_format == REF_STORAGE_FORMAT_UNKNOWN )
3442+ die (_ ("unknown ref storage format '%s'" ), ref_storage_format );
3443+ }
3444+
34313445 add_data .repo = argv [0 ];
34323446 if (argc == 1 )
34333447 add_data .sm_path = git_url_basename (add_data .repo , 0 , 0 );
0 commit comments