@@ -1532,6 +1532,7 @@ struct module_clone_data {
1532
1532
const char * url ;
1533
1533
int depth ;
1534
1534
struct list_objects_filter_options * filter_options ;
1535
+ enum ref_storage_format ref_storage_format ;
1535
1536
unsigned int quiet : 1 ;
1536
1537
unsigned int progress : 1 ;
1537
1538
unsigned int dissociate : 1 ;
@@ -1540,6 +1541,7 @@ struct module_clone_data {
1540
1541
};
1541
1542
#define MODULE_CLONE_DATA_INIT { \
1542
1543
.single_branch = -1, \
1544
+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
1543
1545
}
1544
1546
1545
1547
struct submodule_alternate_setup {
@@ -1738,6 +1740,9 @@ static int clone_submodule(const struct module_clone_data *clone_data,
1738
1740
strvec_pushl (& cp .args , "--reference" ,
1739
1741
item -> string , NULL );
1740
1742
}
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 ));
1741
1746
if (clone_data -> dissociate )
1742
1747
strvec_push (& cp .args , "--dissociate" );
1743
1748
if (sm_gitdir && * sm_gitdir )
@@ -1832,6 +1837,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1832
1837
struct string_list reference = STRING_LIST_INIT_NODUP ;
1833
1838
struct list_objects_filter_options filter_options =
1834
1839
LIST_OBJECTS_FILTER_INIT ;
1840
+ const char * ref_storage_format = NULL ;
1835
1841
1836
1842
struct option module_clone_options [] = {
1837
1843
OPT_STRING (0 , "prefix" , & clone_data .prefix ,
@@ -1849,6 +1855,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1849
1855
OPT_STRING_LIST (0 , "reference" , & reference ,
1850
1856
N_ ("repo" ),
1851
1857
N_ ("reference repository" )),
1858
+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
1859
+ N_ ("specify the reference format to use" )),
1852
1860
OPT_BOOL (0 , "dissociate" , & dissociate ,
1853
1861
N_ ("use --reference only while cloning" )),
1854
1862
OPT_INTEGER (0 , "depth" , & clone_data .depth ,
@@ -1874,6 +1882,11 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1874
1882
argc = parse_options (argc , argv , prefix , module_clone_options ,
1875
1883
git_submodule_helper_usage , 0 );
1876
1884
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
+ }
1877
1890
clone_data .dissociate = !!dissociate ;
1878
1891
clone_data .quiet = !!quiet ;
1879
1892
clone_data .progress = !!progress ;
@@ -1973,6 +1986,7 @@ struct update_data {
1973
1986
struct submodule_update_strategy update_strategy ;
1974
1987
struct list_objects_filter_options * filter_options ;
1975
1988
struct module_list list ;
1989
+ enum ref_storage_format ref_storage_format ;
1976
1990
int depth ;
1977
1991
int max_jobs ;
1978
1992
int single_branch ;
@@ -1996,6 +2010,7 @@ struct update_data {
1996
2010
#define UPDATE_DATA_INIT { \
1997
2011
.update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT, \
1998
2012
.list = MODULE_LIST_INIT, \
2013
+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
1999
2014
.recommend_shallow = -1, \
2000
2015
.references = STRING_LIST_INIT_DUP, \
2001
2016
.single_branch = -1, \
@@ -2131,6 +2146,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
2131
2146
expand_list_objects_filter_spec (suc -> update_data -> filter_options ));
2132
2147
if (suc -> update_data -> require_init )
2133
2148
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 ));
2134
2152
strvec_pushl (& child -> args , "--path" , sub -> path , NULL );
2135
2153
strvec_pushl (& child -> args , "--name" , sub -> name , NULL );
2136
2154
strvec_pushl (& child -> args , "--url" , url , NULL );
@@ -2565,6 +2583,9 @@ static void update_data_to_args(const struct update_data *update_data,
2565
2583
for_each_string_list_item (item , & update_data -> references )
2566
2584
strvec_pushl (args , "--reference" , item -> string , NULL );
2567
2585
}
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 ));
2568
2589
if (update_data -> filter_options && update_data -> filter_options -> choice )
2569
2590
strvec_pushf (args , "--filter=%s" ,
2570
2591
expand_list_objects_filter_spec (
@@ -2740,6 +2761,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2740
2761
struct update_data opt = UPDATE_DATA_INIT ;
2741
2762
struct list_objects_filter_options filter_options =
2742
2763
LIST_OBJECTS_FILTER_INIT ;
2764
+ const char * ref_storage_format = NULL ;
2743
2765
int ret ;
2744
2766
struct option module_update_options [] = {
2745
2767
OPT__SUPER_PREFIX (& opt .super_prefix ),
@@ -2763,6 +2785,8 @@ static int module_update(int argc, const char **argv, const char *prefix)
2763
2785
SM_UPDATE_REBASE ),
2764
2786
OPT_STRING_LIST (0 , "reference" , & opt .references , N_ ("repo" ),
2765
2787
N_ ("reference repository" )),
2788
+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
2789
+ N_ ("specify the reference format to use" )),
2766
2790
OPT_BOOL (0 , "dissociate" , & opt .dissociate ,
2767
2791
N_ ("use --reference only while cloning" )),
2768
2792
OPT_INTEGER (0 , "depth" , & opt .depth ,
@@ -2806,6 +2830,12 @@ static int module_update(int argc, const char **argv, const char *prefix)
2806
2830
module_update_options );
2807
2831
}
2808
2832
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
+
2809
2839
opt .filter_options = & filter_options ;
2810
2840
opt .prefix = prefix ;
2811
2841
@@ -3101,13 +3131,17 @@ struct add_data {
3101
3131
const char * sm_name ;
3102
3132
const char * repo ;
3103
3133
const char * realrepo ;
3134
+ enum ref_storage_format ref_storage_format ;
3104
3135
int depth ;
3105
3136
unsigned int force : 1 ;
3106
3137
unsigned int quiet : 1 ;
3107
3138
unsigned int progress : 1 ;
3108
3139
unsigned int dissociate : 1 ;
3109
3140
};
3110
- #define ADD_DATA_INIT { .depth = -1 }
3141
+ #define ADD_DATA_INIT { \
3142
+ .depth = -1, \
3143
+ .ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN, \
3144
+ }
3111
3145
3112
3146
static void append_fetch_remotes (struct strbuf * msg , const char * git_dir_path )
3113
3147
{
@@ -3201,6 +3235,7 @@ static int add_submodule(const struct add_data *add_data)
3201
3235
3202
3236
string_list_append (& reference , p )-> util = p ;
3203
3237
}
3238
+ clone_data .ref_storage_format = add_data -> ref_storage_format ;
3204
3239
clone_data .dissociate = add_data -> dissociate ;
3205
3240
if (add_data -> depth >= 0 )
3206
3241
clone_data .depth = add_data -> depth ;
@@ -3366,6 +3401,7 @@ static int module_add(int argc, const char **argv, const char *prefix)
3366
3401
{
3367
3402
int force = 0 , quiet = 0 , progress = 0 , dissociate = 0 ;
3368
3403
struct add_data add_data = ADD_DATA_INIT ;
3404
+ const char * ref_storage_format = NULL ;
3369
3405
char * to_free = NULL ;
3370
3406
struct option options [] = {
3371
3407
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)
3376
3412
OPT_BOOL (0 , "progress" , & progress , N_ ("force cloning progress" )),
3377
3413
OPT_STRING (0 , "reference" , & add_data .reference_path , N_ ("repository" ),
3378
3414
N_ ("reference repository" )),
3415
+ OPT_STRING (0 , "ref-format" , & ref_storage_format , N_ ("format" ),
3416
+ N_ ("specify the reference format to use" )),
3379
3417
OPT_BOOL (0 , "dissociate" , & dissociate , N_ ("borrow the objects from reference repositories" )),
3380
3418
OPT_STRING (0 , "name" , & add_data .sm_name , N_ ("name" ),
3381
3419
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)
3402
3440
if (argc == 0 || argc > 2 )
3403
3441
usage_with_options (usage , options );
3404
3442
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
+
3405
3449
add_data .repo = argv [0 ];
3406
3450
if (argc == 1 )
3407
3451
add_data .sm_path = git_url_basename (add_data .repo , 0 , 0 );
0 commit comments