submodule: add --dissociate option to add/update commands
Add --dissociate option to add and update commands, both clone helper commands that already have the --reference option --dissociate pairs with. Signed-off-by: Casey Fitzpatrick <kcghost@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6d33e1c282
commit
a0ef29341a
@ -1056,7 +1056,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
|
||||
static int clone_submodule(const char *path, const char *gitdir, const char *url,
|
||||
const char *depth, struct string_list *reference,
|
||||
const char *depth, struct string_list *reference, int dissociate,
|
||||
int quiet, int progress)
|
||||
{
|
||||
struct child_process cp = CHILD_PROCESS_INIT;
|
||||
@ -1075,6 +1075,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
|
||||
argv_array_pushl(&cp.args, "--reference",
|
||||
item->string, NULL);
|
||||
}
|
||||
if (dissociate)
|
||||
argv_array_push(&cp.args, "--dissociate");
|
||||
if (gitdir && *gitdir)
|
||||
argv_array_pushl(&cp.args, "--separate-git-dir", gitdir, NULL);
|
||||
|
||||
@ -1190,6 +1192,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
|
||||
char *p, *path = NULL, *sm_gitdir;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
struct string_list reference = STRING_LIST_INIT_NODUP;
|
||||
int dissociate = 0;
|
||||
char *sm_alternate = NULL, *error_strategy = NULL;
|
||||
|
||||
struct option module_clone_options[] = {
|
||||
@ -1208,6 +1211,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
|
||||
OPT_STRING_LIST(0, "reference", &reference,
|
||||
N_("repo"),
|
||||
N_("reference repository")),
|
||||
OPT_BOOL(0, "dissociate", &dissociate,
|
||||
N_("use --reference only while cloning")),
|
||||
OPT_STRING(0, "depth", &depth,
|
||||
N_("string"),
|
||||
N_("depth for shallow clones")),
|
||||
@ -1247,7 +1252,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
|
||||
|
||||
prepare_possible_alternates(name, &reference);
|
||||
|
||||
if (clone_submodule(path, sm_gitdir, url, depth, &reference,
|
||||
if (clone_submodule(path, sm_gitdir, url, depth, &reference, dissociate,
|
||||
quiet, progress))
|
||||
die(_("clone of '%s' into submodule path '%s' failed"),
|
||||
url, path);
|
||||
@ -1300,6 +1305,7 @@ struct submodule_update_clone {
|
||||
int quiet;
|
||||
int recommend_shallow;
|
||||
struct string_list references;
|
||||
int dissociate;
|
||||
const char *depth;
|
||||
const char *recursive_prefix;
|
||||
const char *prefix;
|
||||
@ -1315,7 +1321,7 @@ struct submodule_update_clone {
|
||||
int failed_clones_nr, failed_clones_alloc;
|
||||
};
|
||||
#define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
|
||||
SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \
|
||||
SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, 0, \
|
||||
NULL, NULL, NULL, \
|
||||
STRING_LIST_INIT_DUP, 0, NULL, 0, 0}
|
||||
|
||||
@ -1442,6 +1448,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
|
||||
for_each_string_list_item(item, &suc->references)
|
||||
argv_array_pushl(&child->args, "--reference", item->string, NULL);
|
||||
}
|
||||
if (suc->dissociate)
|
||||
argv_array_push(&child->args, "--dissociate");
|
||||
if (suc->depth)
|
||||
argv_array_push(&child->args, suc->depth);
|
||||
|
||||
@ -1575,6 +1583,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
|
||||
N_("rebase, merge, checkout or none")),
|
||||
OPT_STRING_LIST(0, "reference", &suc.references, N_("repo"),
|
||||
N_("reference repository")),
|
||||
OPT_BOOL(0, "dissociate", &suc.dissociate,
|
||||
N_("use --reference only while cloning")),
|
||||
OPT_STRING(0, "depth", &suc.depth, "<depth>",
|
||||
N_("Create a shallow clone truncated to the "
|
||||
"specified number of revisions")),
|
||||
|
Reference in New Issue
Block a user