summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorBen Avison <bavison@riscosopen.org>2019-05-19 14:26:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-28 16:22:02 (GMT)
commit4c6910163ab59f334becca39f5a83d3b7a622df4 (patch)
treebb72bfb03d00e6a15e8187f02a5070fe6c8498ec /builtin
parentab15ad1a3b4b04a29415aef8c9afa2f64fc194a2 (diff)
downloadgit-4c6910163ab59f334becca39f5a83d3b7a622df4.zip
git-4c6910163ab59f334becca39f5a83d3b7a622df4.tar.gz
git-4c6910163ab59f334becca39f5a83d3b7a622df4.tar.bz2
clone: add `--remote-submodules` flag
When using `git clone --recurse-submodules` there was previously no way to pass a `--remote` switch to the implicit `git submodule update` command for any use case where you want the submodules to be checked out on their remote-tracking branch rather than with the SHA-1 recorded in the superproject. This patch rectifies this situation. It actually passes `--no-fetch` to `git submodule update` as well on the grounds they the submodule has only just been cloned, so fetching from the remote again only serves to slow things down. Signed-off-by: Ben Avison <bavison@riscosopen.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/clone.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index ffdd94e..35124aa 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -67,6 +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)
@@ -145,6 +146,8 @@ static struct option builtin_clone_options[] = {
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()
};
@@ -794,6 +797,11 @@ static int checkout(int submodule_progress)
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);
}