@@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
444444 };
445445
446446 const char * const git_submodule_helper_usage [] = {
447- N_ ("git submodule--helper foreach [--quiet] [--recursive] [--] <command>" ),
447+ N_ ("git submodule foreach [--quiet] [--recursive] [--] <command>" ),
448448 NULL
449449 };
450450
@@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
582582 };
583583
584584 const char * const git_submodule_helper_usage [] = {
585- N_ ("git submodule--helper init [<options>] [<path>]" ),
585+ N_ ("git submodule init [<options>] [<path>]" ),
586586 NULL
587587 };
588588
@@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
11851185 };
11861186
11871187 const char * const git_submodule_helper_usage [] = {
1188- N_ ("git submodule--helper summary [<options>] [<commit>] [--] [<path>]" ),
1188+ N_ ("git submodule summary [<options>] [<commit>] [--] [<path>]" ),
11891189 NULL
11901190 };
11911191
@@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
13491349 };
13501350
13511351 const char * const git_submodule_helper_usage [] = {
1352- N_ ("git submodule--helper sync [--quiet] [--recursive] [<path>]" ),
1352+ N_ ("git submodule sync [--quiet] [--recursive] [<path>]" ),
13531353 NULL
13541354 };
13551355
@@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
18181818static void determine_submodule_update_strategy (struct repository * r ,
18191819 int just_cloned ,
18201820 const char * path ,
1821- const char * update ,
1821+ enum submodule_update_type update ,
18221822 struct submodule_update_strategy * out )
18231823{
18241824 const struct submodule * sub = submodule_from_path (r , null_oid (), path );
@@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,
18281828 key = xstrfmt ("submodule.%s.update" , sub -> name );
18291829
18301830 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 ;
18341832 } else if (!repo_config_get_string_tmp (r , key , & val )) {
18351833 if (parse_submodule_update_strategy (val , out ) < 0 )
18361834 die (_ ("Invalid update mode '%s' configured for submodule path '%s'" ),
@@ -1882,7 +1880,7 @@ struct update_data {
18821880 const char * prefix ;
18831881 const char * recursive_prefix ;
18841882 const char * displaypath ;
1885- const char * update_default ;
1883+ enum submodule_update_type update_default ;
18861884 struct object_id suboid ;
18871885 struct string_list references ;
18881886 struct submodule_update_strategy update_strategy ;
@@ -2405,8 +2403,27 @@ static void ensure_core_worktree(const char *path)
24052403 }
24062404}
24072405
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+
24082423static void update_data_to_args (struct update_data * update_data , struct strvec * args )
24092424{
2425+ enum submodule_update_type update_type = update_data -> update_default ;
2426+
24102427 strvec_pushl (args , "submodule--helper" , "update" , "--recursive" , NULL );
24112428 strvec_pushf (args , "--jobs=%d" , update_data -> max_jobs );
24122429 if (update_data -> recursive_prefix )
@@ -2430,8 +2447,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
24302447 strvec_push (args , "--require-init" );
24312448 if (update_data -> depth )
24322449 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+
24352454 if (update_data -> references .nr ) {
24362455 struct string_list_item * item ;
24372456 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)
26012620 N_ ("path" ),
26022621 N_ ("path into the working tree, across nested "
26032622 "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 ),
26072632 OPT_STRING_LIST (0 , "reference" , & opt .references , N_ ("repo" ),
26082633 N_ ("reference repository" )),
26092634 OPT_BOOL (0 , "dissociate" , & opt .dissociate ,
@@ -2619,7 +2644,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
26192644 OPT_BOOL (0 , "progress" , & opt .progress ,
26202645 N_ ("force cloning progress" )),
26212646 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 " )),
26232648 OPT_BOOL (0 , "single-branch" , & opt .single_branch ,
26242649 N_ ("clone only one branch, HEAD or --branch" )),
26252650 OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
@@ -2643,6 +2668,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
26432668 argc = parse_options (argc , argv , prefix , module_update_options ,
26442669 git_submodule_helper_usage , 0 );
26452670
2671+ if (opt .require_init )
2672+ opt .init = 1 ;
2673+
26462674 if (filter_options .choice && !opt .init ) {
26472675 usage_with_options (git_submodule_helper_usage ,
26482676 module_update_options );
@@ -2651,9 +2679,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
26512679 opt .filter_options = & filter_options ;
26522680
26532681 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 ;
26572683
26582684 if (module_list_compute (argc , argv , prefix , & pathspec , & opt .list ) < 0 ) {
26592685 list_objects_filter_release (& filter_options );
@@ -2785,7 +2811,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
27852811 };
27862812
27872813 const char * const git_submodule_helper_usage [] = {
2788- N_ ("git submodule--helper absorb-git-dirs [<options>] [<path>...]" ),
2814+ N_ ("git submodule absorbgitdirs [<options>] [<path>...]" ),
27892815 NULL
27902816 };
27912817
@@ -2890,7 +2916,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
28902916 OPT_END ()
28912917 };
28922918 const char * const usage [] = {
2893- N_ ("git submodule--helper set-url [--quiet] <path> <newurl>" ),
2919+ N_ ("git submodule set-url [--quiet] <path> <newurl>" ),
28942920 NULL
28952921 };
28962922
@@ -2929,8 +2955,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
29292955 OPT_END ()
29302956 };
29312957 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>" ),
29342960 NULL
29352961 };
29362962
@@ -3274,7 +3300,7 @@ static int module_add(int argc, const char **argv, const char *prefix)
32743300 };
32753301
32763302 const char * const usage [] = {
3277- N_ ("git submodule--helper add [<options>] [--] <repository> [<path>]" ),
3303+ N_ ("git submodule add [<options>] [--] <repository> [<path>]" ),
32783304 NULL
32793305 };
32803306
@@ -3387,7 +3413,7 @@ static struct cmd_struct commands[] = {
33873413 {"deinit" , module_deinit , 0 },
33883414 {"summary" , module_summary , SUPPORT_SUPER_PREFIX },
33893415 {"push-check" , push_check , 0 },
3390- {"absorb-git-dirs " , absorb_git_dirs , SUPPORT_SUPER_PREFIX },
3416+ {"absorbgitdirs " , absorb_git_dirs , SUPPORT_SUPER_PREFIX },
33913417 {"is-active" , is_active , 0 },
33923418 {"check-name" , check_name , 0 },
33933419 {"config" , module_config , 0 },
0 commit comments