Skip to content

Commit 89c8626

Browse files
stefanbellergitster
authored andcommitted
submodule helper: support super prefix
Just like main commands in Git, the submodule helper needs access to the superproject prefix. Enable this in the git.c but have its own fuse in the helper code by having a flag to turn on the super prefix. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90c0011 commit 89c8626

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

builtin/submodule--helper.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,21 +1076,24 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,
10761076
return 0;
10771077
}
10781078

1079+
#define SUPPORT_SUPER_PREFIX (1<<0)
1080+
10791081
struct cmd_struct {
10801082
const char *cmd;
10811083
int (*fn)(int, const char **, const char *);
1084+
unsigned option;
10821085
};
10831086

10841087
static struct cmd_struct commands[] = {
1085-
{"list", module_list},
1086-
{"name", module_name},
1087-
{"clone", module_clone},
1088-
{"update-clone", update_clone},
1089-
{"relative-path", resolve_relative_path},
1090-
{"resolve-relative-url", resolve_relative_url},
1091-
{"resolve-relative-url-test", resolve_relative_url_test},
1092-
{"init", module_init},
1093-
{"remote-branch", resolve_remote_submodule_branch}
1088+
{"list", module_list, 0},
1089+
{"name", module_name, 0},
1090+
{"clone", module_clone, 0},
1091+
{"update-clone", update_clone, 0},
1092+
{"relative-path", resolve_relative_path, 0},
1093+
{"resolve-relative-url", resolve_relative_url, 0},
1094+
{"resolve-relative-url-test", resolve_relative_url_test, 0},
1095+
{"init", module_init, 0},
1096+
{"remote-branch", resolve_remote_submodule_branch, 0},
10941097
};
10951098

10961099
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
@@ -1100,9 +1103,15 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
11001103
die(_("submodule--helper subcommand must be "
11011104
"called with a subcommand"));
11021105

1103-
for (i = 0; i < ARRAY_SIZE(commands); i++)
1104-
if (!strcmp(argv[1], commands[i].cmd))
1106+
for (i = 0; i < ARRAY_SIZE(commands); i++) {
1107+
if (!strcmp(argv[1], commands[i].cmd)) {
1108+
if (get_super_prefix() &&
1109+
!(commands[i].option & SUPPORT_SUPER_PREFIX))
1110+
die(_("%s doesn't support --super-prefix"),
1111+
commands[i].cmd);
11051112
return commands[i].fn(argc - 1, argv + 1, prefix);
1113+
}
1114+
}
11061115

11071116
die(_("'%s' is not a valid submodule--helper "
11081117
"subcommand"), argv[1]);

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ static struct cmd_struct commands[] = {
493493
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
494494
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
495495
{ "stripspace", cmd_stripspace },
496-
{ "submodule--helper", cmd_submodule__helper, RUN_SETUP },
496+
{ "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX},
497497
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
498498
{ "tag", cmd_tag, RUN_SETUP },
499499
{ "unpack-file", cmd_unpack_file, RUN_SETUP },

0 commit comments

Comments
 (0)