aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-12-21 14:55:02 -0800
committerJunio C Hamano <gitster@pobox.com>2016-12-21 14:55:02 -0800
commit1123026f0bf6cd6c63e0711ef19567e0048d0b6a (patch)
treef40f5dc13a66c9b158bc224a7bc64ffa552c27aa /builtin
parent3c9979be9be8e0fa309e51df8cc2cacb94a23abf (diff)
parentbf03b790471d57d1bf2a6efca6e0c640c9f37d2e (diff)
downloadgit-1123026f0bf6cd6c63e0711ef19567e0048d0b6a.tar.gz
git-1123026f0bf6cd6c63e0711ef19567e0048d0b6a.tar.xz
Merge branch 'vs/submodule-clone-nested-submodules-alternates'
"git clone --reference $there --recurse-submodules $super" has been taught to guess repositories usable as references for submodules of $super that are embedded in $there while making a clone of the superproject borrow objects from $there; extend the mechanism to also allow submodules of these submodules to borrow repositories embedded in these clones of the submodules embedded in the clone of the superproject. * vs/submodule-clone-nested-submodules-alternates: submodule--helper: set alternateLocation for cloned submodules
Diffstat (limited to 'builtin')
-rw-r--r--builtin/submodule--helper.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4beeda5f9..92fd676a2 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -498,9 +498,9 @@ static int add_possible_reference_from_superproject(
/*
* If the alternate object store is another repository, try the
- * standard layout with .git/modules/<name>/objects
+ * standard layout with .git/(modules/<name>)+/objects
*/
- if (ends_with(alt->path, ".git/objects")) {
+ if (ends_with(alt->path, "/objects")) {
char *sm_alternate;
struct strbuf sb = STRBUF_INIT;
struct strbuf err = STRBUF_INIT;
@@ -583,6 +583,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
struct strbuf rel_path = STRBUF_INIT;
struct strbuf sb = STRBUF_INIT;
struct string_list reference = STRING_LIST_INIT_NODUP;
+ char *sm_alternate = NULL, *error_strategy = NULL;
struct option module_clone_options[] = {
OPT_STRING(0, "prefix", &prefix,
@@ -672,6 +673,20 @@ static int module_clone(int argc, const char **argv, const char *prefix)
die(_("could not get submodule directory for '%s'"), path);
git_config_set_in_file(p, "core.worktree",
relative_path(path, sm_gitdir, &rel_path));
+
+ /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
+ git_config_get_string("submodule.alternateLocation", &sm_alternate);
+ if (sm_alternate)
+ git_config_set_in_file(p, "submodule.alternateLocation",
+ sm_alternate);
+ git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
+ if (error_strategy)
+ git_config_set_in_file(p, "submodule.alternateErrorStrategy",
+ error_strategy);
+
+ free(sm_alternate);
+ free(error_strategy);
+
strbuf_release(&sb);
strbuf_release(&rel_path);
free(sm_gitdir);