Merge branch 'ab/submodule-cleanup' into gc/submodule-use-super-prefix
* ab/submodule-cleanup: git-sh-setup.sh: remove "say" function, change last users git-submodule.sh: use "$quiet", not "$GIT_QUIET" submodule--helper: eliminate internal "--update" option submodule--helper: understand --checkout, --merge and --rebase synonyms submodule--helper: report "submodule" as our name in some "-h" output submodule--helper: rename "absorb-git-dirs" to "absorbgitdirs" submodule update: remove "-v" option submodule--helper: have --require-init imply --init git-submodule.sh: remove unused top-level "--branch" argument git-submodule.sh: make the "$cached" variable a boolean git-submodule.sh: remove unused $prefix variable git-submodule.sh: remove unused sanitize_submodule_env()
This commit is contained in:
@ -444,7 +444,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
|
||||
};
|
||||
|
||||
const char *const git_submodule_helper_usage[] = {
|
||||
N_("git submodule--helper foreach [--quiet] [--recursive] [--] <command>"),
|
||||
N_("git submodule foreach [--quiet] [--recursive] [--] <command>"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -582,7 +582,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
|
||||
};
|
||||
|
||||
const char *const git_submodule_helper_usage[] = {
|
||||
N_("git submodule--helper init [<options>] [<path>]"),
|
||||
N_("git submodule init [<options>] [<path>]"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -1185,7 +1185,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
|
||||
};
|
||||
|
||||
const char *const git_submodule_helper_usage[] = {
|
||||
N_("git submodule--helper summary [<options>] [<commit>] [--] [<path>]"),
|
||||
N_("git submodule summary [<options>] [<commit>] [--] [<path>]"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -1349,7 +1349,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
|
||||
};
|
||||
|
||||
const char *const git_submodule_helper_usage[] = {
|
||||
N_("git submodule--helper sync [--quiet] [--recursive] [<path>]"),
|
||||
N_("git submodule sync [--quiet] [--recursive] [<path>]"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -1818,7 +1818,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
|
||||
static void determine_submodule_update_strategy(struct repository *r,
|
||||
int just_cloned,
|
||||
const char *path,
|
||||
const char *update,
|
||||
enum submodule_update_type update,
|
||||
struct submodule_update_strategy *out)
|
||||
{
|
||||
const struct submodule *sub = submodule_from_path(r, null_oid(), path);
|
||||
@ -1828,9 +1828,7 @@ static void determine_submodule_update_strategy(struct repository *r,
|
||||
key = xstrfmt("submodule.%s.update", sub->name);
|
||||
|
||||
if (update) {
|
||||
if (parse_submodule_update_strategy(update, out) < 0)
|
||||
die(_("Invalid update mode '%s' for submodule path '%s'"),
|
||||
update, path);
|
||||
out->type = update;
|
||||
} else if (!repo_config_get_string_tmp(r, key, &val)) {
|
||||
if (parse_submodule_update_strategy(val, out) < 0)
|
||||
die(_("Invalid update mode '%s' configured for submodule path '%s'"),
|
||||
@ -1882,7 +1880,7 @@ struct update_data {
|
||||
const char *prefix;
|
||||
const char *recursive_prefix;
|
||||
const char *displaypath;
|
||||
const char *update_default;
|
||||
enum submodule_update_type update_default;
|
||||
struct object_id suboid;
|
||||
struct string_list references;
|
||||
struct submodule_update_strategy update_strategy;
|
||||
@ -2405,8 +2403,27 @@ 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)
|
||||
{
|
||||
enum submodule_update_type update_type = update_data->update_default;
|
||||
|
||||
strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL);
|
||||
strvec_pushf(args, "--jobs=%d", update_data->max_jobs);
|
||||
if (update_data->recursive_prefix)
|
||||
@ -2430,8 +2447,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
|
||||
strvec_push(args, "--require-init");
|
||||
if (update_data->depth)
|
||||
strvec_pushf(args, "--depth=%d", update_data->depth);
|
||||
if (update_data->update_default)
|
||||
strvec_pushl(args, "--update", update_data->update_default, NULL);
|
||||
if (update_type != SM_UPDATE_UNSPECIFIED)
|
||||
strvec_pushf(args, "--%s",
|
||||
submodule_update_type_to_label(update_type));
|
||||
|
||||
if (update_data->references.nr) {
|
||||
struct string_list_item *item;
|
||||
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)
|
||||
N_("path"),
|
||||
N_("path into the working tree, across nested "
|
||||
"submodule boundaries")),
|
||||
OPT_STRING(0, "update", &opt.update_default,
|
||||
N_("string"),
|
||||
N_("rebase, merge, checkout or none")),
|
||||
OPT_SET_INT(0, "checkout", &opt.update_default,
|
||||
N_("use the 'checkout' update strategy (default)"),
|
||||
SM_UPDATE_CHECKOUT),
|
||||
OPT_SET_INT('m', "merge", &opt.update_default,
|
||||
N_("use the 'merge' update strategy"),
|
||||
SM_UPDATE_MERGE),
|
||||
OPT_SET_INT('r', "rebase", &opt.update_default,
|
||||
N_("use the 'rebase' update strategy"),
|
||||
SM_UPDATE_REBASE),
|
||||
OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"),
|
||||
N_("reference repository")),
|
||||
OPT_BOOL(0, "dissociate", &opt.dissociate,
|
||||
@ -2619,7 +2644,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||
OPT_BOOL(0, "progress", &opt.progress,
|
||||
N_("force cloning progress")),
|
||||
OPT_BOOL(0, "require-init", &opt.require_init,
|
||||
N_("disallow cloning into non-empty directory")),
|
||||
N_("disallow cloning into non-empty directory, implies --init")),
|
||||
OPT_BOOL(0, "single-branch", &opt.single_branch,
|
||||
N_("clone only one branch, HEAD or --branch")),
|
||||
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
|
||||
@ -2643,6 +2668,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||
argc = parse_options(argc, argv, prefix, module_update_options,
|
||||
git_submodule_helper_usage, 0);
|
||||
|
||||
if (opt.require_init)
|
||||
opt.init = 1;
|
||||
|
||||
if (filter_options.choice && !opt.init) {
|
||||
usage_with_options(git_submodule_helper_usage,
|
||||
module_update_options);
|
||||
@ -2651,9 +2679,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
|
||||
opt.filter_options = &filter_options;
|
||||
|
||||
if (opt.update_default)
|
||||
if (parse_submodule_update_strategy(opt.update_default,
|
||||
&opt.update_strategy) < 0)
|
||||
die(_("bad value for update parameter"));
|
||||
opt.update_strategy.type = opt.update_default;
|
||||
|
||||
if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {
|
||||
list_objects_filter_release(&filter_options);
|
||||
@ -2785,7 +2811,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
|
||||
};
|
||||
|
||||
const char *const git_submodule_helper_usage[] = {
|
||||
N_("git submodule--helper absorb-git-dirs [<options>] [<path>...]"),
|
||||
N_("git submodule absorbgitdirs [<options>] [<path>...]"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -2890,7 +2916,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
|
||||
OPT_END()
|
||||
};
|
||||
const char *const usage[] = {
|
||||
N_("git submodule--helper set-url [--quiet] <path> <newurl>"),
|
||||
N_("git submodule set-url [--quiet] <path> <newurl>"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -2929,8 +2955,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
|
||||
OPT_END()
|
||||
};
|
||||
const char *const usage[] = {
|
||||
N_("git submodule--helper set-branch [-q|--quiet] (-d|--default) <path>"),
|
||||
N_("git submodule--helper set-branch [-q|--quiet] (-b|--branch) <branch> <path>"),
|
||||
N_("git submodule set-branch [-q|--quiet] (-d|--default) <path>"),
|
||||
N_("git submodule set-branch [-q|--quiet] (-b|--branch) <branch> <path>"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -3274,7 +3300,7 @@ static int module_add(int argc, const char **argv, const char *prefix)
|
||||
};
|
||||
|
||||
const char *const usage[] = {
|
||||
N_("git submodule--helper add [<options>] [--] <repository> [<path>]"),
|
||||
N_("git submodule add [<options>] [--] <repository> [<path>]"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -3387,7 +3413,7 @@ static struct cmd_struct commands[] = {
|
||||
{"deinit", module_deinit, 0},
|
||||
{"summary", module_summary, SUPPORT_SUPER_PREFIX},
|
||||
{"push-check", push_check, 0},
|
||||
{"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX},
|
||||
{"absorbgitdirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX},
|
||||
{"is-active", is_active, 0},
|
||||
{"check-name", check_name, 0},
|
||||
{"config", module_config, 0},
|
||||
|
Reference in New Issue
Block a user