From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, jacob.keller@gmail.com,
Stefan Beller <sbeller@google.com>
Subject: [PATCH 1/3] submodule clone: pass along `local` option
Date: Tue, 12 Apr 2016 16:48:47 -0700 [thread overview]
Message-ID: <1460504929-19208-2-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <1460504929-19208-1-git-send-email-sbeller@google.com>
When cloning a local repository, the user may choose to use an optimization
such that the transfer uses a Git agnostic protocol. Propagate the users
choice to submodules or if they don't choose, propagate nothing.
A test will be added in a later patch.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/clone.c | 14 ++++++++++++++
builtin/submodule--helper.c | 22 +++++++++++++++++++---
git-submodule.sh | 7 +++++++
3 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index b004fb4..7453244 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -727,6 +727,20 @@ static int checkout(void)
struct argv_array args = ARGV_ARRAY_INIT;
argv_array_pushl(&args, "submodule", "update", "--init", "--recursive", NULL);
+ switch (option_local) {
+ case 1:
+ argv_array_push(&args, "--local");
+ break;
+ case 0:
+ argv_array_push(&args, "--no-local");
+ break;
+ case -1:
+ /* pass nothing */
+ break;
+ default:
+ die("BUG: option_local out of range");
+ }
+
if (max_jobs != -1)
argv_array_pushf(&args, "--jobs=%d", max_jobs);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index a484945..822ec69 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -125,7 +125,8 @@ static int module_name(int argc, const char **argv, const char *prefix)
return 0;
}
static int clone_submodule(const char *path, const char *gitdir, const char *url,
- const char *depth, const char *reference, int quiet)
+ const char *depth, const char *reference, int quiet,
+ int local)
{
struct child_process cp;
child_process_init(&cp);
@@ -140,6 +141,10 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
argv_array_pushl(&cp.args, "--reference", reference, NULL);
if (gitdir && *gitdir)
argv_array_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
+ if (local == 1)
+ argv_array_push(&cp.args, "--local");
+ else if (!local)
+ argv_array_push(&cp.args, "--no-local");
argv_array_push(&cp.args, url);
argv_array_push(&cp.args, path);
@@ -156,6 +161,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
const char *path = NULL, *name = NULL, *url = NULL;
const char *reference = NULL, *depth = NULL;
int quiet = 0;
+ int local = -1;
FILE *submodule_dot_git;
char *sm_gitdir, *cwd, *p;
struct strbuf rel_path = STRBUF_INIT;
@@ -180,6 +186,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
OPT_STRING(0, "depth", &depth,
N_("string"),
N_("depth for shallow clones")),
+ OPT_BOOL(0, "local", &local,
+ N_("to clone from a local repository")),
OPT__QUIET(&quiet, "Suppress output for cloning a submodule"),
OPT_END()
};
@@ -200,7 +208,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
if (!file_exists(sm_gitdir)) {
if (safe_create_leading_directories_const(sm_gitdir) < 0)
die(_("could not create directory '%s'"), sm_gitdir);
- if (clone_submodule(path, sm_gitdir, url, depth, reference, quiet))
+ if (clone_submodule(path, sm_gitdir, url, depth, reference,
+ quiet, local))
die(_("clone of '%s' into submodule path '%s' failed"),
url, path);
} else {
@@ -266,6 +275,7 @@ struct submodule_update_clone {
/* configuration parameters which are passed on to the children */
int quiet;
+ int local;
const char *reference;
const char *depth;
const char *recursive_prefix;
@@ -278,7 +288,7 @@ struct submodule_update_clone {
unsigned quickstop : 1;
};
#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
- SUBMODULE_UPDATE_STRATEGY_INIT, 0, NULL, NULL, NULL, NULL, \
+ SUBMODULE_UPDATE_STRATEGY_INIT, 0, -1, NULL, NULL, NULL, NULL, \
STRING_LIST_INIT_DUP, 0}
/**
@@ -367,6 +377,10 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
child->err = -1;
argv_array_push(&child->args, "submodule--helper");
argv_array_push(&child->args, "clone");
+ if (suc->local == 1)
+ argv_array_push(&child->args, "--local");
+ else if (!suc->local)
+ argv_array_push(&child->args, "--no-local");
if (suc->quiet)
argv_array_push(&child->args, "--quiet");
if (suc->prefix)
@@ -451,6 +465,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
OPT_STRING(0, "depth", &suc.depth, "<depth>",
N_("Create a shallow clone truncated to the "
"specified number of revisions")),
+ OPT_BOOL(0, "local", &suc.local,
+ N_("to clone from a local repository")),
OPT_INTEGER('j', "jobs", &max_jobs,
N_("parallel jobs")),
OPT__QUIET(&suc.quiet, N_("don't print cloning progress")),
diff --git a/git-submodule.sh b/git-submodule.sh
index 86018ee..4d5e8c7 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -653,6 +653,12 @@ cmd_update()
--jobs=*)
jobs=$1
;;
+ --local)
+ option_local="--local"
+ ;;
+ --no-local)
+ option_local="--no-local"
+ ;;
--)
shift
break
@@ -680,6 +686,7 @@ cmd_update()
${reference:+--reference "$reference"} \
${depth:+--depth "$depth"} \
${jobs:+$jobs} \
+ ${option_local:+$option_local} \
"$@" || echo "#unmatched"
} | {
err=
--
2.5.0.264.gc776916.dirty
next prev parent reply other threads:[~2016-04-12 23:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-12 23:48 [PATCH 0/3] clone --shallow-submodules flag Stefan Beller
2016-04-12 23:48 ` Stefan Beller [this message]
2016-04-25 12:18 ` [PATCH 1/3] submodule clone: pass along `local` option Lars Schneider
2016-04-25 17:15 ` Stefan Beller
2016-04-12 23:48 ` [PATCH 2/3] clone: add `--shallow-submodules` flag Stefan Beller
2016-04-12 23:48 ` [PATCH 3/3] clone: add t5614 to test cloning submodules with shallowness involved Stefan Beller
2016-04-13 6:52 ` Jacob Keller
2016-04-25 17:41 ` Stefan Beller
2016-04-25 12:25 ` Lars Schneider
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=1460504929-19208-2-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.keller@gmail.com \
/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).