@@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
444
444
};
445
445
446
446
const char * const git_submodule_helper_usage [] = {
447
- N_ ("git submodule--helper foreach [--quiet] [--recursive] [--] <command>" ),
447
+ N_ ("git submodule foreach [--quiet] [--recursive] [--] <command>" ),
448
448
NULL
449
449
};
450
450
@@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
582
582
};
583
583
584
584
const char * const git_submodule_helper_usage [] = {
585
- N_ ("git submodule--helper init [<options>] [<path>]" ),
585
+ N_ ("git submodule init [<options>] [<path>]" ),
586
586
NULL
587
587
};
588
588
@@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
1185
1185
};
1186
1186
1187
1187
const char * const git_submodule_helper_usage [] = {
1188
- N_ ("git submodule--helper summary [<options>] [<commit>] [--] [<path>]" ),
1188
+ N_ ("git submodule summary [<options>] [<commit>] [--] [<path>]" ),
1189
1189
NULL
1190
1190
};
1191
1191
@@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
1349
1349
};
1350
1350
1351
1351
const char * const git_submodule_helper_usage [] = {
1352
- N_ ("git submodule--helper sync [--quiet] [--recursive] [<path>]" ),
1352
+ N_ ("git submodule sync [--quiet] [--recursive] [<path>]" ),
1353
1353
NULL
1354
1354
};
1355
1355
@@ -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,7 @@ struct update_data {
1882
1880
const char * prefix ;
1883
1881
const char * recursive_prefix ;
1884
1882
const char * displaypath ;
1885
- const char * update_default ;
1883
+ enum submodule_update_type update_default ;
1886
1884
struct object_id suboid ;
1887
1885
struct string_list references ;
1888
1886
struct submodule_update_strategy update_strategy ;
@@ -2405,8 +2403,27 @@ static void ensure_core_worktree(const char *path)
2405
2403
}
2406
2404
}
2407
2405
2406
+ static const char * submodule_update_type_to_label (enum submodule_update_type type )
2407
+ {
2408
+ switch (type ) {
2409
+ case SM_UPDATE_CHECKOUT :
2410
+ return "checkout" ;
2411
+ case SM_UPDATE_MERGE :
2412
+ return "merge" ;
2413
+ case SM_UPDATE_REBASE :
2414
+ return "rebase" ;
2415
+ case SM_UPDATE_UNSPECIFIED :
2416
+ case SM_UPDATE_NONE :
2417
+ case SM_UPDATE_COMMAND :
2418
+ break ;
2419
+ }
2420
+ BUG ("unreachable with type %d" , type );
2421
+ }
2422
+
2408
2423
static void update_data_to_args (struct update_data * update_data , struct strvec * args )
2409
2424
{
2425
+ enum submodule_update_type update_type = update_data -> update_default ;
2426
+
2410
2427
strvec_pushl (args , "submodule--helper" , "update" , "--recursive" , NULL );
2411
2428
strvec_pushf (args , "--jobs=%d" , update_data -> max_jobs );
2412
2429
if (update_data -> recursive_prefix )
@@ -2430,8 +2447,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
2430
2447
strvec_push (args , "--require-init" );
2431
2448
if (update_data -> depth )
2432
2449
strvec_pushf (args , "--depth=%d" , update_data -> depth );
2433
- if (update_data -> update_default )
2434
- strvec_pushl (args , "--update" , update_data -> update_default , NULL );
2450
+ if (update_type != SM_UPDATE_UNSPECIFIED )
2451
+ strvec_pushf (args , "--%s" ,
2452
+ submodule_update_type_to_label (update_type ));
2453
+
2435
2454
if (update_data -> references .nr ) {
2436
2455
struct string_list_item * item ;
2437
2456
for_each_string_list_item (item , & update_data -> references )
@@ -2601,9 +2620,15 @@ static int module_update(int argc, const char **argv, const char *prefix)
2601
2620
N_ ("path" ),
2602
2621
N_ ("path into the working tree, across nested "
2603
2622
"submodule boundaries" )),
2604
- OPT_STRING (0 , "update" , & opt .update_default ,
2605
- N_ ("string" ),
2606
- N_ ("rebase, merge, checkout or none" )),
2623
+ OPT_SET_INT (0 , "checkout" , & opt .update_default ,
2624
+ N_ ("use the 'checkout' update strategy (default)" ),
2625
+ SM_UPDATE_CHECKOUT ),
2626
+ OPT_SET_INT ('m' , "merge" , & opt .update_default ,
2627
+ N_ ("use the 'merge' update strategy" ),
2628
+ SM_UPDATE_MERGE ),
2629
+ OPT_SET_INT ('r' , "rebase" , & opt .update_default ,
2630
+ N_ ("use the 'rebase' update strategy" ),
2631
+ SM_UPDATE_REBASE ),
2607
2632
OPT_STRING_LIST (0 , "reference" , & opt .references , N_ ("repo" ),
2608
2633
N_ ("reference repository" )),
2609
2634
OPT_BOOL (0 , "dissociate" , & opt .dissociate ,
@@ -2619,7 +2644,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2619
2644
OPT_BOOL (0 , "progress" , & opt .progress ,
2620
2645
N_ ("force cloning progress" )),
2621
2646
OPT_BOOL (0 , "require-init" , & opt .require_init ,
2622
- N_ ("disallow cloning into non-empty directory" )),
2647
+ N_ ("disallow cloning into non-empty directory, implies --init " )),
2623
2648
OPT_BOOL (0 , "single-branch" , & opt .single_branch ,
2624
2649
N_ ("clone only one branch, HEAD or --branch" )),
2625
2650
OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
@@ -2643,6 +2668,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
2643
2668
argc = parse_options (argc , argv , prefix , module_update_options ,
2644
2669
git_submodule_helper_usage , 0 );
2645
2670
2671
+ if (opt .require_init )
2672
+ opt .init = 1 ;
2673
+
2646
2674
if (filter_options .choice && !opt .init ) {
2647
2675
usage_with_options (git_submodule_helper_usage ,
2648
2676
module_update_options );
@@ -2651,9 +2679,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2651
2679
opt .filter_options = & filter_options ;
2652
2680
2653
2681
if (opt .update_default )
2654
- if (parse_submodule_update_strategy (opt .update_default ,
2655
- & opt .update_strategy ) < 0 )
2656
- die (_ ("bad value for update parameter" ));
2682
+ opt .update_strategy .type = opt .update_default ;
2657
2683
2658
2684
if (module_list_compute (argc , argv , prefix , & pathspec , & opt .list ) < 0 ) {
2659
2685
list_objects_filter_release (& filter_options );
@@ -2785,7 +2811,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
2785
2811
};
2786
2812
2787
2813
const char * const git_submodule_helper_usage [] = {
2788
- N_ ("git submodule--helper absorb-git-dirs [<options>] [<path>...]" ),
2814
+ N_ ("git submodule absorbgitdirs [<options>] [<path>...]" ),
2789
2815
NULL
2790
2816
};
2791
2817
@@ -2890,7 +2916,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
2890
2916
OPT_END ()
2891
2917
};
2892
2918
const char * const usage [] = {
2893
- N_ ("git submodule--helper set-url [--quiet] <path> <newurl>" ),
2919
+ N_ ("git submodule set-url [--quiet] <path> <newurl>" ),
2894
2920
NULL
2895
2921
};
2896
2922
@@ -2929,8 +2955,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
2929
2955
OPT_END ()
2930
2956
};
2931
2957
const char * const usage [] = {
2932
- N_ ("git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>" ),
2933
- N_ ("git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>" ),
2958
+ N_ ("git submodule set-branch [-q|--quiet] (-d|--default) <path>" ),
2959
+ N_ ("git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>" ),
2934
2960
NULL
2935
2961
};
2936
2962
@@ -3274,7 +3300,7 @@ static int module_add(int argc, const char **argv, const char *prefix)
3274
3300
};
3275
3301
3276
3302
const char * const usage [] = {
3277
- N_ ("git submodule--helper add [<options>] [--] <repository> [<path>]" ),
3303
+ N_ ("git submodule add [<options>] [--] <repository> [<path>]" ),
3278
3304
NULL
3279
3305
};
3280
3306
@@ -3387,7 +3413,7 @@ static struct cmd_struct commands[] = {
3387
3413
{"deinit" , module_deinit , 0 },
3388
3414
{"summary" , module_summary , SUPPORT_SUPER_PREFIX },
3389
3415
{"push-check" , push_check , 0 },
3390
- {"absorb-git-dirs " , absorb_git_dirs , SUPPORT_SUPER_PREFIX },
3416
+ {"absorbgitdirs " , absorb_git_dirs , SUPPORT_SUPER_PREFIX },
3391
3417
{"is-active" , is_active , 0 },
3392
3418
{"check-name" , check_name , 0 },
3393
3419
{"config" , module_config , 0 },
0 commit comments