From: Junio C Hamano Date: Mon, 17 Jun 2019 17:15:17 +0000 (-0700) Subject: Merge branch 'ba/clone-remote-submodules' X-Git-Tag: v2.23.0-rc0~117 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/94760948f17e1902e071172677e0615da6e03d90?ds=inline;hp=-c Merge branch 'ba/clone-remote-submodules' "git clone --recurse-submodules" learned to set up the submodules to ignore commit object names recorded in the superproject gitlink and instead use the commits that happen to be at the tip of the remote-tracking branches from the get-go, by passing the new "--remote-submodules" option. * ba/clone-remote-submodules: clone: add `--remote-submodules` flag --- 94760948f17e1902e071172677e0615da6e03d90 diff --combined builtin/clone.c index e3231864ca,35124aa044..bb864d2101 --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -67,6 -67,7 +67,7 @@@ static int max_jobs = -1 static struct string_list option_recurse_submodules = STRING_LIST_INIT_NODUP; static struct list_objects_filter_options filter_options; static struct string_list server_options = STRING_LIST_INIT_NODUP; + static int option_remote_submodules; static int recurse_submodules_cb(const struct option *opt, const char *arg, int unset) @@@ -99,7 -100,10 +100,7 @@@ static struct option builtin_clone_opti N_("don't use local hardlinks, always copy")), OPT_BOOL('s', "shared", &option_shared, N_("setup as shared repository")), - { OPTION_CALLBACK, 0, "recursive", &option_recurse_submodules, - N_("pathspec"), N_("initialize submodules in the clone"), - PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, recurse_submodules_cb, - (intptr_t)"." }, + OPT_ALIAS(0, "recursive", "recurse-submodules"), { OPTION_CALLBACK, 0, "recurse-submodules", &option_recurse_submodules, N_("pathspec"), N_("initialize submodules in the clone"), PARSE_OPT_OPTARG, recurse_submodules_cb, (intptr_t)"." }, @@@ -142,6 -146,8 +143,8 @@@ OPT_SET_INT('6', "ipv6", &family, N_("use IPv6 addresses only"), TRANSPORT_FAMILY_IPV6), OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), + OPT_BOOL(0, "remote-submodules", &option_remote_submodules, + N_("any cloned submodules will use their remote-tracking branch")), OPT_END() }; @@@ -354,7 -360,8 +357,7 @@@ static void setup_reference(void add_one_reference, &required); } -static void copy_alternates(struct strbuf *src, struct strbuf *dst, - const char *src_repo) +static void copy_alternates(struct strbuf *src, const char *src_repo) { /* * Read from the source objects/info/alternates file @@@ -435,7 -442,7 +438,7 @@@ static void copy_or_link_directory(stru /* Files that cannot be copied bit-for-bit... */ if (!strcmp(src->buf + src_baselen, "/info/alternates")) { - copy_alternates(src, dest, src_repo); + copy_alternates(src, src_repo); continue; } @@@ -790,6 -797,11 +793,11 @@@ static int checkout(int submodule_progr if (option_verbosity < 0) argv_array_push(&args, "--quiet"); + if (option_remote_submodules) { + argv_array_push(&args, "--remote"); + argv_array_push(&args, "--no-fetch"); + } + err = run_command_v_opt(args.argv, RUN_GIT_CMD); argv_array_clear(&args); }