1818
static void determine_submodule_update_strategy(struct repository *r,
1819
int just_cloned,
1820
const char *path,
1821
- const char *update,
1821
+ enum submodule_update_type update,
1822
struct submodule_update_strategy *out)
1823
{
1824
const struct submodule *sub = submodule_from_path(r, null_oid(), path);
1828
key = xstrfmt("submodule.%s.update", sub->name);
1829
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;
1832
} else if (!repo_config_get_string_tmp(r, key, &val)) {
1833
if (parse_submodule_update_strategy(val, out) < 0)
1834
die(_("Invalid update mode '%s' configured for submodule path '%s'"),
1880
const char *prefix;
1881
const char *recursive_prefix;
1882
const char *displaypath;
1885
- const char *update_default;
1883
+ enum submodule_update_type update_default;
1884
struct object_id suboid;
1885
struct string_list references;
1886
struct submodule_update_strategy update_strategy;
2421
2422
static void update_data_to_args(struct update_data *update_data, struct strvec *args)
2423
{
2424
+ enum submodule_update_type update_type = update_data->update_default;
2425
+
2426
strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL);
2427
strvec_pushf(args, "--jobs=%d", update_data->max_jobs);
2428
if (update_data->recursive_prefix)
2446
strvec_push(args, "--require-init");
2447
if (update_data->depth)
2448
strvec_pushf(args, "--depth=%d", update_data->depth);
2449
- if (update_data->update_default)
2450
- strvec_pushl(args, "--update", update_data->update_default, NULL);
2449
+ if (update_type != SM_UPDATE_UNSPECIFIED)
2450
+ strvec_pushf(args, "--%s",
2451
+ submodule_update_type_to_label(update_type));
2452
+
2453
if (update_data->references.nr) {
2454
struct string_list_item *item;
2455
for_each_string_list_item(item, &update_data->references)
2601
struct update_data opt = UPDATE_DATA_INIT;
2602
struct list_objects_filter_options filter_options;
2603
int ret;
2602
- enum submodule_update_type update_type = SM_UPDATE_UNSPECIFIED;
2604
2605
struct option module_update_options[] = {
2606
OPT__FORCE(&opt.force, N_("force checkout updates"), 0),
2619
N_("path"),
2620
N_("path into the working tree, across nested "
2621
"submodule boundaries")),
2621
- OPT_STRING(0, "update", &opt.update_default,
2622
- N_("string"),
2623
- N_("rebase, merge, checkout or none")),
2624
- OPT_SET_INT(0, "checkout", &update_type,
2622
+ OPT_SET_INT(0, "checkout", &opt.update_default,
2623
N_("use the 'checkout' update strategy (default)"),
2624
SM_UPDATE_CHECKOUT),
2627
- OPT_SET_INT('m', "merge", &update_type,
2625
+ OPT_SET_INT('m', "merge", &opt.update_default,
2626
N_("use the 'merge' update strategy"),
2627
SM_UPDATE_MERGE),
2630
- OPT_SET_INT('r', "rebase", &update_type,
2628
+ OPT_SET_INT('r', "rebase", &opt.update_default,
2629
N_("use the 'rebase' update strategy"),
2630
SM_UPDATE_REBASE),
2631
OPT_STRING_LIST(0, "reference", &opt.references, N_("repo"),
2677
2678
opt.filter_options = &filter_options;
2679
2682
- if (update_type != SM_UPDATE_UNSPECIFIED)
2683
- opt.update_default = submodule_update_type_to_label(update_type);
2684
-
2680
if (opt.update_default)
2686
- if (parse_submodule_update_strategy(opt.update_default,
2687
- &opt.update_strategy) < 0)
2688
- die(_("bad value for update parameter"));
2681
+ opt.update_strategy.type = opt.update_default;
2682
2683
if (module_list_compute(argc, argv, prefix, &pathspec, &opt.list) < 0) {
2684
list_objects_filter_release(&filter_options);