Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
submodule--helper module-clone: allow multiple references
author
Stefan Beller
<sbeller@google.com>
Thu, 11 Aug 2016 23:14:00 +0000
(16:14 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 12 Aug 2016 22:00:17 +0000
(15:00 -0700)
Allow users to pass in multiple references, just as clone accepts multiple
references as well.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
9292536
)
diff --git
a/builtin/submodule--helper.c
b/builtin/submodule--helper.c
index 6f6d67a4694a83f18f86f5de2d9d64fd4e449a5e..ce9b3e9bb886ffb4c170b9c1482025be04181dff 100644
(file)
--- a/
builtin/submodule--helper.c
+++ b/
builtin/submodule--helper.c
@@
-442,7
+442,7
@@
static int module_name(int argc, const char **argv, const char *prefix)
}
static int clone_submodule(const char *path, const char *gitdir, const char *url,
}
static int clone_submodule(const char *path, const char *gitdir, const char *url,
- const char *depth,
const char
*reference, int quiet)
+ const char *depth,
struct string_list
*reference, int quiet)
{
struct child_process cp;
child_process_init(&cp);
{
struct child_process cp;
child_process_init(&cp);
@@
-453,8
+453,12
@@
static int clone_submodule(const char *path, const char *gitdir, const char *url
argv_array_push(&cp.args, "--quiet");
if (depth && *depth)
argv_array_pushl(&cp.args, "--depth", depth, NULL);
argv_array_push(&cp.args, "--quiet");
if (depth && *depth)
argv_array_pushl(&cp.args, "--depth", depth, NULL);
- if (reference && *reference)
- argv_array_pushl(&cp.args, "--reference", reference, NULL);
+ if (reference->nr) {
+ struct string_list_item *item;
+ for_each_string_list_item(item, reference)
+ argv_array_pushl(&cp.args, "--reference",
+ item->string, NULL);
+ }
if (gitdir && *gitdir)
argv_array_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
if (gitdir && *gitdir)
argv_array_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
@@
-470,13
+474,13
@@
static int clone_submodule(const char *path, const char *gitdir, const char *url
static int module_clone(int argc, const char **argv, const char *prefix)
{
static int module_clone(int argc, const char **argv, const char *prefix)
{
- const char *name = NULL, *url = NULL;
- const char *reference = NULL, *depth = NULL;
+ const char *name = NULL, *url = NULL, *depth = NULL;
int quiet = 0;
FILE *submodule_dot_git;
char *p, *path = NULL, *sm_gitdir;
struct strbuf rel_path = STRBUF_INIT;
struct strbuf sb = STRBUF_INIT;
int quiet = 0;
FILE *submodule_dot_git;
char *p, *path = NULL, *sm_gitdir;
struct strbuf rel_path = STRBUF_INIT;
struct strbuf sb = STRBUF_INIT;
+ struct string_list reference = STRING_LIST_INIT_NODUP;
struct option module_clone_options[] = {
OPT_STRING(0, "prefix", &prefix,
struct option module_clone_options[] = {
OPT_STRING(0, "prefix", &prefix,
@@
-491,8
+495,8
@@
static int module_clone(int argc, const char **argv, const char *prefix)
OPT_STRING(0, "url", &url,
N_("string"),
N_("url where to clone the submodule from")),
OPT_STRING(0, "url", &url,
N_("string"),
N_("url where to clone the submodule from")),
- OPT_STRING(0, "reference", &reference,
- N_("
string
"),
+ OPT_STRING
_LIST
(0, "reference", &reference,
+ N_("
repo
"),
N_("reference repository")),
OPT_STRING(0, "depth", &depth,
N_("string"),
N_("reference repository")),
OPT_STRING(0, "depth", &depth,
N_("string"),
@@
-528,7
+532,7
@@
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 (!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))
die(_("clone of '%s' into submodule path '%s' failed"),
url, path);
} else {
die(_("clone of '%s' into submodule path '%s' failed"),
url, path);
} else {