@@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1818
1818
static void determine_submodule_update_strategy (struct repository * r ,
1819
1819
int just_cloned ,
1820
1820
const char * path ,
1821
- const char * update ,
1821
+ enum submodule_update_type update ,
1822
1822
struct submodule_update_strategy * out )
1823
1823
{
1824
1824
const struct submodule * sub = submodule_from_path (r , null_oid (), path );
@@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,
1828
1828
key = xstrfmt ("submodule.%s.update" , sub -> name );
1829
1829
1830
1830
if (update ) {
1831
- if (parse_submodule_update_strategy (update , out ) < 0 )
1832
- die (_ ("Invalid update mode '%s' for submodule path '%s'" ),
1833
- update , path );
1831
+ out -> type = update ;
1834
1832
} else if (!repo_config_get_string_tmp (r , key , & val )) {
1835
1833
if (parse_submodule_update_strategy (val , out ) < 0 )
1836
1834
die (_ ("Invalid update mode '%s' configured for submodule path '%s'" ),
@@ -1882,7 +1880,6 @@ struct update_data {
1882
1880
const char * prefix ;
1883
1881
const char * recursive_prefix ;
1884
1882
const char * displaypath ;
1885
- const char * update_default ;
1886
1883
struct object_id suboid ;
1887
1884
struct string_list references ;
1888
1885
struct submodule_update_strategy update_strategy ;
@@ -1892,6 +1889,7 @@ struct update_data {
1892
1889
int max_jobs ;
1893
1890
int single_branch ;
1894
1891
int recommend_shallow ;
1892
+ enum submodule_update_type update_default ;
1895
1893
unsigned int require_init ;
1896
1894
unsigned int force ;
1897
1895
unsigned int quiet ;
@@ -2429,8 +2427,20 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
2429
2427
strvec_push (args , "--require-init" );
2430
2428
if (update_data -> depth )
2431
2429
strvec_pushf (args , "--depth=%d" , update_data -> depth );
2432
- if (update_data -> update_default )
2433
- strvec_pushl (args , "--update" , update_data -> update_default , NULL );
2430
+ switch (update_data -> update_default ) {
2431
+ case SM_UPDATE_MERGE :
2432
+ strvec_push (args , "--merge" );
2433
+ break ;
2434
+ case SM_UPDATE_CHECKOUT :
2435
+ strvec_push (args , "--checkout" );
2436
+ break ;
2437
+ case SM_UPDATE_REBASE :
2438
+ strvec_push (args , "--rebase" );
2439
+ break ;
2440
+ default :
2441
+ break ;
2442
+ }
2443
+
2434
2444
if (update_data -> references .nr ) {
2435
2445
struct string_list_item * item ;
2436
2446
for_each_string_list_item (item , & update_data -> references )
@@ -2600,9 +2610,12 @@ static int module_update(int argc, const char **argv, const char *prefix)
2600
2610
N_ ("path" ),
2601
2611
N_ ("path into the working tree, across nested "
2602
2612
"submodule boundaries" )),
2603
- OPT_STRING (0 , "update" , & opt .update_default ,
2604
- N_ ("string" ),
2605
- N_ ("rebase, merge, checkout or none" )),
2613
+ OPT_SET_INT (0 , "checkout" , & opt .update_default ,
2614
+ N_ ("update using checkout" ), SM_UPDATE_CHECKOUT ),
2615
+ OPT_SET_INT ('r' , "rebase" , & opt .update_default ,
2616
+ N_ ("update using rebase" ), SM_UPDATE_REBASE ),
2617
+ OPT_SET_INT ('m' , "merge" , & opt .update_default ,
2618
+ N_ ("update using merge" ), SM_UPDATE_MERGE ),
2606
2619
OPT_STRING_LIST (0 , "reference" , & opt .references , N_ ("repo" ),
2607
2620
N_ ("reference repository" )),
2608
2621
OPT_BOOL (0 , "dissociate" , & opt .dissociate ,
@@ -2654,9 +2667,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2654
2667
opt .filter_options = & filter_options ;
2655
2668
2656
2669
if (opt .update_default )
2657
- if (parse_submodule_update_strategy (opt .update_default ,
2658
- & opt .update_strategy ) < 0 )
2659
- die (_ ("bad value for update parameter" ));
2670
+ opt .update_strategy .type = opt .update_default ;
2660
2671
2661
2672
if (module_list_compute (argc , argv , prefix , & pathspec , & opt .list ) < 0 ) {
2662
2673
list_objects_filter_release (& filter_options );
0 commit comments