Skip to contentSkip to conversation

submodule--helper: set alternateLocation for cloned submodules

PATCH In review [email protected] 3 participants 4 messages Dec 8, 2016 – Dec 12, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 submodule--helper: set alternateLocation for cloned submodules

From: "Vitaly \"_Vi\" Shukela" <[email protected]>

In 31224cbdc7 (clone: recursive and reference option triggers submodule alternates, 2016-08-17) a mechanism was added to have submodules referenced. It did not address _nested_ submodules, however.

This patch makes all not just the root repository, but also all submodules (recursively) have submodule.alternateLocation and submodule.alternateErrorStrategy configured, making Git search for possible alternates for nested submodules as well.

As submodule's alternate target does not end in .git/objects (rather .git/modules/qqqqqq/objects), this alternate target path restriction for in add_possible_reference_from_superproject relates from "*.git/objects" to just */objects".

New tests have been added to t7408-submodule-reference.

---

Notes:
Third review: missing && in test fixed.

Mailmap change not included.

 builtin/submodule--helper.c    | 19 ++++++++++--
 t/t7408-submodule-reference.sh | 66 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 2 deletions(-)
builtin/submodule--helper.c +17 -2
index 4beeda5..92fd676 100644
@@ -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);
t/t7408-submodule-reference.sh +66 -0

70 lines not on this page · raw message

Signature · 1 line
2.10.2
author
#1 lore raw
Quoted 2 lines · On 12/08/2016 04:38 AM, [email protected] wrote:
     Third review: missing && in test fixed.

Shall something more be done about this or just wait until the patch gets reviewed and integrated?

#2 lore raw
Quoted 7 lines · On Sat, Dec 10, 2016 at 5:41 AM, vi0oss <[email protected]> wrote:
Quoted 3 lines · On 12/08/2016 04:38 AM, [email protected] wrote:
     Third review: missing && in test fixed.

Shall something more be done about this or just wait until the patch gets reviewed and integrated?

I have no further comments and think the most recent version you sent to the list
is fine. However others are invited to comment as well. :)

Thanks,
Stefan

#3 lore raw
Quoted 6 lines · Stefan Beller
Quoted 5 lines · On Sat, Dec 10, 2016 at 5:41 AM, vi0oss <[email protected]> wrote:
Quoted 3 lines · On 12/08/2016 04:38 AM, [email protected] wrote:
     Third review: missing && in test fixed.
Quoted 6 lines
Quoted 2 lines

Shall something more be done about this or just wait until the patch gets reviewed and integrated?

I have no further comments and think the most recent version you sent to the list
is fine. However others are invited to comment as well. :)

I'll take that as a reviewed-by from you and queue it.

Thanks, both.