From: Cole Minnaar <cole.minnaar@gmail.com>
To: git@vger.kernel.org
Cc: Cole Minnaar <cole.minnaar@gmail.com>, Jens.Lehmann@web.de
Subject: [PATCH/RFC v2 2/2] submodule: modify clone command to recursively shallow clone submodules
Date: Mon, 15 Sep 2014 12:42:01 +0200 [thread overview]
Message-ID: <1410777721-602-2-git-send-email-cole.minnaar@gmail.com> (raw)
In-Reply-To: <1410777721-602-1-git-send-email-cole.minnaar@gmail.com>
When cloning a repository that contains submodules and specifying the
`--depth` option to the 'git clone' command, the top level repository will be
cloned with the specified depth, but all submodules within the
repository will be cloned in their entirety.
Modified 'git clone' to pass the `--depth` option, if specified, to any
submodule clone commands.
Modified 'git clone' to pass the `--no-single-branch`, if specified, to any
submodule clone commands.
Signed-off-by: Cole Minnaar <cole.minnaar@gmail.com>
---
Documentation/git-clone.txt | 5 ++++-
builtin/clone.c | 15 +++++++++------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 0363d00..7621251 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -178,7 +178,8 @@ objects from the source repository into a pack in the cloned repository.
--depth <depth>::
Create a 'shallow' clone with a history truncated to the
- specified number of revisions.
+ specified number of revisions. If `--recursive` was also specified
+ the depth value will be passed to all submodules within when cloning.
--[no-]single-branch::
Clone only the history leading to the tip of a single branch,
@@ -192,6 +193,8 @@ objects from the source repository into a pack in the cloned repository.
initial cloning. If the HEAD at the remote did not point at any
branch when `--single-branch` clone was made, no remote-tracking
branch is created.
+ If `--recursive` was also specified, this option will be passed to
+ all submodules when cloning.
--recursive::
--recurse-submodules::
diff --git a/builtin/clone.c b/builtin/clone.c
index dd4092b..b27917c 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -48,6 +48,7 @@ static int option_verbosity;
static int option_progress = -1;
static struct string_list option_config;
static struct string_list option_reference;
+static struct argv_array argv_submodule_cmd = ARGV_ARRAY_INIT;
static int opt_parse_reference(const struct option *opt, const char *arg, int unset)
{
@@ -100,10 +101,6 @@ static struct option builtin_clone_options[] = {
OPT_END()
};
-static const char *argv_submodule[] = {
- "submodule", "update", "--init", "--recursive", NULL
-};
-
static char *get_repo_path(const char *repo, int *is_bundle)
{
static char *suffix[] = { "/.git", "", ".git/.git", ".git" };
@@ -663,8 +660,14 @@ static int checkout(void)
err |= run_hook_le(NULL, "post-checkout", sha1_to_hex(null_sha1),
sha1_to_hex(sha1), "1", NULL);
- if (!err && option_recursive)
- err = run_command_v_opt(argv_submodule, RUN_GIT_CMD);
+ if (!err && option_recursive) {
+ argv_array_pushl(&argv_submodule_cmd, "submodule", "update", "--init", "--recursive", NULL);
+ if (option_depth)
+ argv_array_pushf(&argv_submodule_cmd, "--depth=%d", atoi(option_depth));
+ if (!option_single_branch)
+ argv_array_pushl(&argv_submodule_cmd, "--no-single-branch", NULL);
+ err = run_command_v_opt(argv_submodule_cmd.argv, RUN_GIT_CMD);
+ }
return err;
}
--
2.1.0.240.g8a0e823
next prev parent reply other threads:[~2014-09-15 10:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 10:42 [PATCH/RFC v2 1/2] submodule: add ability to shallowly clone any branch in a repo as a submodule Cole Minnaar
2014-09-15 10:42 ` Cole Minnaar [this message]
2014-11-16 9:55 ` Yoni Tsafir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410777721-602-2-git-send-email-cole.minnaar@gmail.com \
--to=cole.minnaar@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).