submodule--helper: understand --checkout, --merge and --rebase synonyms
Understand --checkout, --merge and --rebase synonyms for
--update={checkout,merge,rebase}, as well as the short options that
'git submodule' itself understands.
This removes a difference between the CLI API of "git submodule" and
"git submodule--helper", making it easier to make the latter an alias
for the former. See 48308681b0
(git submodule update: have a
dedicated helper for cloning, 2016-02-29) for the initial addition of
--update.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
parent
36d45163b6
commit
8f12108c29
|
@ -2404,6 +2404,23 @@ static void ensure_core_worktree(const char *path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *submodule_update_type_to_label(enum submodule_update_type type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SM_UPDATE_CHECKOUT:
|
||||||
|
return "checkout";
|
||||||
|
case SM_UPDATE_MERGE:
|
||||||
|
return "merge";
|
||||||
|
case SM_UPDATE_REBASE:
|
||||||
|
return "rebase";
|
||||||
|
case SM_UPDATE_UNSPECIFIED:
|
||||||
|
case SM_UPDATE_NONE:
|
||||||
|
case SM_UPDATE_COMMAND:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BUG("unreachable with type %d", type);
|
||||||
|
}
|
||||||
|
|
||||||
static void update_data_to_args(struct update_data *update_data, struct strvec *args)
|
static void update_data_to_args(struct update_data *update_data, struct strvec *args)
|
||||||
{
|
{
|
||||||
strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL);
|
strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL);
|
||||||
|
@ -2582,6 +2599,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||||
struct update_data opt = UPDATE_DATA_INIT;
|
struct update_data opt = UPDATE_DATA_INIT;
|
||||||
struct list_objects_filter_options filter_options;
|
struct list_objects_filter_options filter_options;
|
||||||
int ret;
|
int ret;
|
||||||
|
enum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;
|
||||||
|
|
||||||
struct option module_update_options[] = {
|
struct option module_update_options[] = {
|
||||||
OPT__FORCE(&opt.force, N_("force checkout updates"), 0),
|
OPT__FORCE(&opt.force, N_("force checkout updates"), 0),
|
||||||
|
@ -2603,6 +2621,15 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||||
OPT_STRING(0, "update", &opt.update_default,
|
OPT_STRING(0, "update", &opt.update_default,
|
||||||
N_("string"),
|
N_("string"),
|
||||||
N_("rebase, merge, checkout or none")),
|
N_("rebase, merge, checkout or none")),
|
||||||
|
OPT_SET_INT(0, "checkout", &update_type,
|
||||||
|
N_("use the 'checkout' update strategy (default)"),
|
||||||
|
SM_UPDATE_CHECKOUT),
|
||||||
|
OPT_SET_INT('m', "merge", &update_type,
|
||||||
|
N_("use the 'merge' update strategy"),
|
||||||
|
SM_UPDATE_MERGE),
|
||||||
|
OPT_SET_INT('r', "rebase", &update_type,
|
||||||
|
N_("use the 'rebase' update strategy"),
|
||||||
|
SM_UPDATE_REBASE),
|
||||||
OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"),
|
OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"),
|
||||||
N_("reference repository")),
|
N_("reference repository")),
|
||||||
OPT_BOOL(0, "dissociate", &opt.dissociate,
|
OPT_BOOL(0, "dissociate", &opt.dissociate,
|
||||||
|
@ -2652,6 +2679,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
opt.filter_options = &filter_options;
|
opt.filter_options = &filter_options;
|
||||||
|
|
||||||
|
if (update_type != SM_UPDATE_UNSPECIFIED)
|
||||||
|
opt.update_default = submodule_update_type_to_label(update_type);
|
||||||
|
|
||||||
if (opt.update_default)
|
if (opt.update_default)
|
||||||
if (parse_submodule_update_strategy(opt.update_default,
|
if (parse_submodule_update_strategy(opt.update_default,
|
||||||
&opt.update_strategy) < 0)
|
&opt.update_strategy) < 0)
|
||||||
|
|
|
@ -40,7 +40,9 @@ require_init=
|
||||||
files=
|
files=
|
||||||
remote=
|
remote=
|
||||||
nofetch=
|
nofetch=
|
||||||
update=
|
rebase=
|
||||||
|
merge=
|
||||||
|
checkout=
|
||||||
custom_name=
|
custom_name=
|
||||||
depth=
|
depth=
|
||||||
progress=
|
progress=
|
||||||
|
@ -260,7 +262,7 @@ cmd_update()
|
||||||
force=$1
|
force=$1
|
||||||
;;
|
;;
|
||||||
-r|--rebase)
|
-r|--rebase)
|
||||||
update="rebase"
|
rebase=1
|
||||||
;;
|
;;
|
||||||
--reference)
|
--reference)
|
||||||
case "$2" in '') usage ;; esac
|
case "$2" in '') usage ;; esac
|
||||||
|
@ -274,13 +276,13 @@ cmd_update()
|
||||||
dissociate=1
|
dissociate=1
|
||||||
;;
|
;;
|
||||||
-m|--merge)
|
-m|--merge)
|
||||||
update="merge"
|
merge=1
|
||||||
;;
|
;;
|
||||||
--recursive)
|
--recursive)
|
||||||
recursive=1
|
recursive=1
|
||||||
;;
|
;;
|
||||||
--checkout)
|
--checkout)
|
||||||
update="checkout"
|
checkout=1
|
||||||
;;
|
;;
|
||||||
--recommend-shallow)
|
--recommend-shallow)
|
||||||
recommend_shallow="--recommend-shallow"
|
recommend_shallow="--recommend-shallow"
|
||||||
|
@ -341,7 +343,9 @@ cmd_update()
|
||||||
${init:+--init} \
|
${init:+--init} \
|
||||||
${nofetch:+--no-fetch} \
|
${nofetch:+--no-fetch} \
|
||||||
${wt_prefix:+--prefix "$wt_prefix"} \
|
${wt_prefix:+--prefix "$wt_prefix"} \
|
||||||
${update:+--update "$update"} \
|
${rebase:+--rebase} \
|
||||||
|
${merge:+--merge} \
|
||||||
|
${checkout:+--checkout} \
|
||||||
${reference:+"$reference"} \
|
${reference:+"$reference"} \
|
||||||
${dissociate:+"--dissociate"} \
|
${dissociate:+"--dissociate"} \
|
||||||
${depth:+"$depth"} \
|
${depth:+"$depth"} \
|
||||||
|
|
Loading…
Reference in New Issue