builtin/submodule--helper.c: rename option struct to "opt"

In a later commit, update_clone()'s options will be stored in a struct
update_data instead of submodule_update_clone. Preemptively rename the
options struct to "opt" to shrink that commit's diff.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-03-15 14:09:21 -07:00 committed by Junio C Hamano
parent 55b3f12cb5
commit 49fd5b99a5

View File

@ -2498,40 +2498,40 @@ static int update_clone(int argc, const char **argv, const char *prefix)
{
const char *update = NULL;
struct pathspec pathspec;
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
struct submodule_update_clone opt = SUBMODULE_UPDATE_CLONE_INIT;
struct list_objects_filter_options filter_options;
int ret;
struct option module_update_clone_options[] = {
OPT_BOOL(0, "init", &suc.init,
OPT_BOOL(0, "init", &opt.init,
N_("initialize uninitialized submodules before update")),
OPT_STRING(0, "prefix", &prefix,
N_("path"),
N_("path into the working tree")),
OPT_STRING(0, "recursive-prefix", &suc.recursive_prefix,
OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix,
N_("path"),
N_("path into the working tree, across nested "
"submodule boundaries")),
OPT_STRING(0, "update", &update,
N_("string"),
N_("rebase, merge, checkout or none")),
OPT_STRING_LIST(0, "reference", &suc.references, N_("repo"),
OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"),
N_("reference repository")),
OPT_BOOL(0, "dissociate", &suc.dissociate,
OPT_BOOL(0, "dissociate", &opt.dissociate,
N_("use --reference only while cloning")),
OPT_STRING(0, "depth", &suc.depth, "<depth>",
OPT_STRING(0, "depth", &opt.depth, "<depth>",
N_("create a shallow clone truncated to the "
"specified number of revisions")),
OPT_INTEGER('j', "jobs", &suc.max_jobs,
OPT_INTEGER('j', "jobs", &opt.max_jobs,
N_("parallel jobs")),
OPT_BOOL(0, "recommend-shallow", &suc.recommend_shallow,
OPT_BOOL(0, "recommend-shallow", &opt.recommend_shallow,
N_("whether the initial clone should follow the shallow recommendation")),
OPT__QUIET(&suc.quiet, N_("don't print cloning progress")),
OPT_BOOL(0, "progress", &suc.progress,
OPT__QUIET(&opt.quiet, N_("don't print cloning progress")),
OPT_BOOL(0, "progress", &opt.progress,
N_("force cloning progress")),
OPT_BOOL(0, "require-init", &suc.require_init,
OPT_BOOL(0, "require-init", &opt.require_init,
N_("disallow cloning into non-empty directory")),
OPT_BOOL(0, "single-branch", &suc.single_branch,
OPT_BOOL(0, "single-branch", &opt.single_branch,
N_("clone only one branch, HEAD or --branch")),
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
OPT_END()
@ -2546,16 +2546,16 @@ static int update_clone(int argc, const char **argv, const char *prefix)
" [--recursive] [--[no-]single-branch] [--] [<path>...]"),
NULL
};
suc.prefix = prefix;
opt.prefix = prefix;
update_clone_config_from_gitmodules(&suc.max_jobs);
git_config(git_update_clone_config, &suc.max_jobs);
update_clone_config_from_gitmodules(&opt.max_jobs);
git_config(git_update_clone_config, &opt.max_jobs);
memset(&filter_options, 0, sizeof(filter_options));
argc = parse_options(argc, argv, prefix, module_update_clone_options,
git_submodule_helper_usage, 0);
if (filter_options.choice && !suc.init) {
if (filter_options.choice && !opt.init) {
/*
* NEEDSWORK: Don't use usage_with_options() because the
* usage string is for "git submodule update", but the
@ -2567,25 +2567,25 @@ static int update_clone(int argc, const char **argv, const char *prefix)
usage(git_submodule_helper_usage[0]);
}
suc.filter_options = &filter_options;
opt.filter_options = &filter_options;
if (update)
if (parse_submodule_update_strategy(update, &suc.update) < 0)
if (parse_submodule_update_strategy(update, &opt.update) < 0)
die(_("bad value for update parameter"));
if (module_list_compute(argc, argv, prefix, &pathspec, &suc.list) < 0) {
if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {
list_objects_filter_release(&filter_options);
return 1;
}
if (pathspec.nr)
suc.warn_if_uninitialized = 1;
opt.warn_if_uninitialized = 1;
if (suc.init) {
if (opt.init) {
struct module_list list = MODULE_LIST_INIT;
struct init_cb info = INIT_CB_INIT;
if (module_list_compute(argc, argv, suc.prefix,
if (module_list_compute(argc, argv, opt.prefix,
&pathspec, &list) < 0)
return 1;
@ -2596,15 +2596,15 @@ static int update_clone(int argc, const char **argv, const char *prefix)
if (!argc && git_config_get_value_multi("submodule.active"))
module_list_active(&list);
info.prefix = suc.prefix;
info.superprefix = suc.recursive_prefix;
if (suc.quiet)
info.prefix = opt.prefix;
info.superprefix = opt.recursive_prefix;
if (opt.quiet)
info.flags |= OPT_QUIET;
for_each_listed_submodule(&list, init_submodule_cb, &info);
}
ret = update_submodules(&suc);
ret = update_submodules(&opt);
list_objects_filter_release(&filter_options);
return ret;
}