git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] clone: remember references for submodules even when not recursing

From
Stefan Beller <sbeller@google.com>
Date
Apr 11, 2017, 19:46 UTC
Message-ID
<20170411194616.4963-3-sbeller@google.com>
In-Reply-To
<20170411194616.4963-1-sbeller@google.com>

The commit 31224cbdc7 (clone: recursive and reference option triggers submodule alternates, 2016-08-17) argued for any further `submodule update` to respect the initial setup. This is not the case if you only pass '--reference[-if-able]' to the initial clone without instructing to recurse into submodules.

If there are submodules however the user is likely to later run a 'submodule update --init' to obtain the submodules. In this case we also want to have the references available.

Reported-by: Maxime Viargues <maxime.viargues@serato.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/clone.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index de85b85254..5f022e39e9 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "connected.h"
+#include "submodule.h"
 
 /*
  * Overall FIXMEs:
@@ -993,11 +994,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			string_list_append(&option_config,
 					   strbuf_detach(&sb, NULL));
 		}
+	}
 
+	if (option_recurse_submodules.nr ||
+	    has_submodules(SUBMODULE_CHECK_GITMODULES_IN_WT)) {
 		if (option_required_reference.nr &&
 		    option_optional_reference.nr)
-			die(_("clone --recursive is not compatible with "
-			      "both --reference and --reference-if-able"));
+			die(_("submodules are incompatible with both "
+			    "--reference and --reference-if-able"));
 		else if (option_required_reference.nr) {
 			string_list_append(&option_config,
 				"submodule.alternateLocation=superproject");
-- 
2.12.2.575.gb14f27f917
Previous: Brandon WilliamsNext: Brandon Williams
Message 6 of 9 in “clone: record submodule alternates when not recursing”
  1. 0/2 clone: record submodule alternates when not recursingStefan Beller, Apr 11, 2017
  2. 1/2 submodule.c: add has_submodules to check if we have any submodulesStefan Beller, Apr 11, 2017
  3. Brandon WilliamsApr 20, 2017
  4. Stefan BellerApr 20, 2017
  5. Brandon WilliamsApr 20, 2017
  6. 2/2 clone: remember references for submodules even when not recursingStefan Beller, Apr 11, 2017
  7. Brandon WilliamsApr 20, 2017
  8. Stefan BellerApr 20, 2017
  9. Stefan BellerApr 19, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.