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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Dec 8, 2016 at 13:03 UTC
89c8626557621ef000930da3c8a23fa03ad7e01a
2 files changed
+21
-12
builtin/submodule--helper.c
+20
-11
@@ -1076,21 +1076,24 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,
1076
return 0;
1077
}
1078
1079
+#define SUPPORT_SUPER_PREFIX (1<<0)
1080
+
1081
struct cmd_struct {
1082
const char *cmd;
1083
int (*fn)(int, const char **, const char *);
1084
+ unsigned option;
1085
};
1086
1087
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},
1097
};
1098
1099
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)
1103
die(_("submodule--helper subcommand must be "
1104
"called with a subcommand"));
1105
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);
1112
return commands[i].fn(argc - 1, argv + 1, prefix);
1113
+ }
1114
+ }
1115
1116
die(_("'%s' is not a valid submodule--helper "
1117
"subcommand"), argv[1]);
git.c
+1
-1
@@ -493,7 +493,7 @@ static struct cmd_struct commands[] = {
493
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
494
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
495
{ "stripspace", cmd_stripspace },
496
- { "submodule--helper", cmd_submodule__helper, RUN_SETUP },
496
+ { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX},
497
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
498
{ "tag", cmd_tag, RUN_SETUP },
499
{ "unpack-file", cmd_unpack_file, RUN_SETUP },