Skip to content

Commit d7a714f

Browse files
chooglengitster
authored andcommitted
submodule--helper update: use --super-prefix
Unlike the other subcommands, "git submodule--helper update" uses the "--recursive-prefix" flag instead of "--super-prefix". The two flags are otherwise identical (they only serve to compute the 'display path' of a submodule), except that there is a dedicated helper function to get the value of "--super-prefix". This inconsistency exists because "git submodule update" used to pass "--recursive-prefix" between shell and C (introduced in [1]) before "--super-prefix" was introduced (in [2]), and for simplicity, we kept this name when "git submodule--helper update" was created. Remove "--recursive-prefix" and its associated code from "git submodule--helper update", replacing it with "--super-prefix". To use "--super-prefix", module_update is marked with SUPPORT_SUPER_PREFIX. Note that module_clone must also be marked with SUPPORT_SUPER_PREFIX, otherwise the "git submodule--helper clone" subprocess will fail check because "--super-prefix" is propagated via the environment. [1] 4830868 (git submodule update: have a dedicated helper for cloning, 2016-02-29) [2] 74866d7 (git: make super-prefix option, 2016-10-07) Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b0f8b21 commit d7a714f

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

builtin/submodule--helper.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,18 @@ static int starts_with_dot_dot_slash(const char *const path)
477477

478478
struct init_cb {
479479
const char *prefix;
480-
const char *superprefix;
481480
unsigned int flags;
482481
};
483482
#define INIT_CB_INIT { 0 }
484483

485484
static void init_submodule(const char *path, const char *prefix,
486-
const char *superprefix, unsigned int flags)
485+
unsigned int flags)
487486
{
488487
const struct submodule *sub;
489488
struct strbuf sb = STRBUF_INIT;
490489
char *upd = NULL, *url = NULL, *displaypath;
491490

492-
/* try superprefix from the environment, if it is not passed explicitly */
493-
if (!superprefix)
494-
superprefix = get_super_prefix();
495-
displaypath = do_get_submodule_displaypath(path, prefix, superprefix);
491+
displaypath = do_get_submodule_displaypath(path, prefix, get_super_prefix());
496492

497493
sub = submodule_from_path(the_repository, null_oid(), path);
498494

@@ -566,7 +562,7 @@ static void init_submodule(const char *path, const char *prefix,
566562
static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data)
567563
{
568564
struct init_cb *info = cb_data;
569-
init_submodule(list_item->name, info->prefix, info->superprefix, info->flags);
565+
init_submodule(list_item->name, info->prefix, info->flags);
570566
}
571567

572568
static int module_init(int argc, const char **argv, const char *prefix)
@@ -1878,7 +1874,6 @@ struct submodule_update_clone {
18781874

18791875
struct update_data {
18801876
const char *prefix;
1881-
const char *recursive_prefix;
18821877
const char *displaypath;
18831878
enum submodule_update_type update_default;
18841879
struct object_id suboid;
@@ -1949,7 +1944,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
19491944
char *key;
19501945
struct update_data *ud = suc->update_data;
19511946
char *displaypath = do_get_submodule_displaypath(ce->name, ud->prefix,
1952-
ud->recursive_prefix);
1947+
get_super_prefix());
19531948
struct strbuf sb = STRBUF_INIT;
19541949
int needs_cloning = 0;
19551950
int need_free_url = 0;
@@ -2415,12 +2410,12 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
24152410
{
24162411
enum submodule_update_type update_type = update_data->update_default;
24172412

2418-
strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL);
2419-
strvec_pushf(args, "--jobs=%d", update_data->max_jobs);
24202413
if (update_data->displaypath) {
2421-
strvec_push(args, "--recursive-prefix");
2414+
strvec_push(args, "--super-prefix");
24222415
strvec_pushf(args, "%s/", update_data->displaypath);
24232416
}
2417+
strvec_pushl(args, "submodule--helper", "update", "--recursive", NULL);
2418+
strvec_pushf(args, "--jobs=%d", update_data->max_jobs);
24242419
if (update_data->quiet)
24252420
strvec_push(args, "--quiet");
24262421
if (update_data->force)
@@ -2468,7 +2463,7 @@ static int update_submodule(struct update_data *update_data)
24682463

24692464
update_data->displaypath = do_get_submodule_displaypath(update_data->sm_path,
24702465
update_data->prefix,
2471-
update_data->recursive_prefix);
2466+
get_super_prefix());
24722467

24732468
determine_submodule_update_strategy(the_repository, update_data->just_cloned,
24742469
update_data->sm_path, update_data->update_default,
@@ -2592,10 +2587,6 @@ static int module_update(int argc, const char **argv, const char *prefix)
25922587
OPT_STRING(0, "prefix", &opt.prefix,
25932588
N_("path"),
25942589
N_("path into the working tree")),
2595-
OPT_STRING(0, "recursive-prefix", &opt.recursive_prefix,
2596-
N_("path"),
2597-
N_("path into the working tree, across nested "
2598-
"submodule boundaries")),
25992590
OPT_SET_INT(0, "checkout", &opt.update_default,
26002591
N_("use the 'checkout' update strategy (default)"),
26012592
SM_UPDATE_CHECKOUT),
@@ -2681,7 +2672,6 @@ static int module_update(int argc, const char **argv, const char *prefix)
26812672
module_list_active(&list);
26822673

26832674
info.prefix = opt.prefix;
2684-
info.superprefix = opt.recursive_prefix;
26852675
if (opt.quiet)
26862676
info.flags |= OPT_QUIET;
26872677

@@ -3378,9 +3368,9 @@ struct cmd_struct {
33783368
static struct cmd_struct commands[] = {
33793369
{"list", module_list, 0},
33803370
{"name", module_name, 0},
3381-
{"clone", module_clone, 0},
3371+
{"clone", module_clone, SUPPORT_SUPER_PREFIX},
33823372
{"add", module_add, 0},
3383-
{"update", module_update, 0},
3373+
{"update", module_update, SUPPORT_SUPER_PREFIX},
33843374
{"resolve-relative-url-test", resolve_relative_url_test, 0},
33853375
{"foreach", module_foreach, SUPPORT_SUPER_PREFIX},
33863376
{"init", module_init, 0},

0 commit comments

Comments
 (0)