Discussions turned out that we cannot parallelize the whole loop below `git submodule--helper list` in `git submodule update`, because some changes should be done only one at a time, such as messing up a submodule and leave it up to the user to cleanup the conflicted rebase or merge.
The submodules which are need to be cloned however do not expect to create problems which require attention by the user one at a time, so we want to parallelize that first. To do so we will start with a literal copy of `git submodule--helper list` and port over features gradually. Signed-off-by: Stefan Beller <sbel...@google.com> --- builtin/submodule--helper.c | 40 ++++++++++++++++++++++++++++++++++++++++ git-submodule.sh | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index f4c3eff..47dc9cb 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -255,6 +255,45 @@ static int module_clone(int argc, const char **argv, const char *prefix) return 0; } +static int module_list_or_clone(int argc, const char **argv, const char *prefix) +{ + int i; + struct pathspec pathspec; + struct module_list list = MODULE_LIST_INIT; + + struct option module_list_options[] = { + OPT_STRING(0, "prefix", &prefix, + N_("path"), + N_("alternative anchor for relative paths")), + OPT_END() + }; + + const char *const git_submodule_helper_usage[] = { + N_("git submodule--helper list [--prefix=<path>] [<path>...]"), + NULL + }; + + argc = parse_options(argc, argv, prefix, module_list_options, + git_submodule_helper_usage, 0); + + if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) { + printf("#unmatched\n"); + return 1; + } + + for (i = 0; i < list.nr; i++) { + const struct cache_entry *ce = list.entries[i]; + + if (ce_stage(ce)) + printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1)); + else + printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), ce_stage(ce)); + + utf8_fprintf(stdout, "%s\n", ce->name); + } + return 0; +} + struct cmd_struct { const char *cmd; int (*fn)(int, const char **, const char *); @@ -264,6 +303,7 @@ static struct cmd_struct commands[] = { {"list", module_list}, {"name", module_name}, {"clone", module_clone}, + {"list-or-clone", module_list_or_clone} }; int cmd_submodule__helper(int argc, const char **argv, const char *prefix) diff --git a/git-submodule.sh b/git-submodule.sh index bb8b2c7..d2d80e2 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -656,7 +656,7 @@ cmd_update() fi cloned_modules= - git submodule--helper list --prefix "$wt_prefix" "$@" | { + git submodule--helper list-or-clone --prefix "$wt_prefix" "$@" | { err= while read mode sha1 stage sm_path do -- 2.5.0.277.gfdc362b.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html