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

[PATCH 2/3] submodule: only suggest submodulePathConfig when it is disabled

From
Adrian Ratiu <adrian.ratiu@collabora.com>
Date
Nov 18, 2026, 16:32 UTC
Message-ID
<20261118163249.1693361-3-adrian.ratiu@collabora.com>
In-Reply-To
<20261118163249.1693361-1-adrian.ratiu@collabora.com>

When a recursive checkout refuses to use a submodule's git dir, the error message ends with:

  Enabling extensions.submodulePathConfig should fix this.

This is printed even when the extension is already enabled, which is confusing: the user is told to turn on something that is already on.

Move the suggestion into a separate hint, as submodule_name_to_gitdir() already does, and only show it when the extension is disabled.

Reported-by: Andreas Wendleder <gonsolo@gmail.com>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
 submodule.c                                | 10 ++++++----
 t/t7425-submodule-gitdir-path-extension.sh | 14 ++++++++++++++
 t/t7450-bad-git-dotfiles.sh                |  1 +
 3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/submodule.c b/submodule.c
index d00d820d42..64cd8005f7 100644
--- a/submodule.c
+++ b/submodule.c
@@ -2171,11 +2171,13 @@ int submodule_move_head(const char *path, const char *super_prefix,
 
 				free(dotgit);
 				if (validate_submodule_git_dir(git_dir,
-							       sub->name) < 0)
+							       sub->name) < 0) {
+					if (!the_repository->repository_format_submodule_path_cfg)
+						advise(_("enabling extensions.submodulePathConfig "
+							 "might fix the following error."));
 					die(_("refusing to create/use '%s' in "
-					      "another submodule's git dir. "
-					      "Enabling extensions.submodulePathConfig "
-					      "should fix this."), git_dir);
+					      "another submodule's git dir."), git_dir);
+				}
 				free(git_dir);
 			}
 		} else {
diff --git a/t/t7425-submodule-gitdir-path-extension.sh b/t/t7425-submodule-gitdir-path-extension.sh
index ea86ecf7ee..80438a7231 100755
--- a/t/t7425-submodule-gitdir-path-extension.sh
+++ b/t/t7425-submodule-gitdir-path-extension.sh
@@ -525,4 +525,18 @@ test_expect_success 'submodule gitdir conflicts with previously encoded name (lo
 	)
 '
 
+test_expect_success 'rejected submodule gitfile does not suggest enabling the extension' '
+	git clone -c extensions.submodulePathConfig=true --recurse-submodules nested clone_moved_gitdir &&
+	(
+		cd clone_moved_gitdir &&
+		mkdir .git/modules/zoo &&
+		mv .git/modules/hippo .git/modules/zoo/hippo &&
+		git config set -f .git/modules/zoo/hippo/config core.worktree ../../../../thing1 &&
+		echo "gitdir: ../.git/modules/zoo/hippo" >thing1/.git
+	) &&
+	test_must_fail git -C clone_moved_gitdir checkout -f --recurse-submodules HEAD 2>err &&
+	test_grep "refusing to create/use" err &&
+	test_grep ! "extensions.submodulePathConfig" err
+'
+
 test_done
diff --git a/t/t7450-bad-git-dotfiles.sh b/t/t7450-bad-git-dotfiles.sh
index e17642fc16..a710c05a5d 100755
--- a/t/t7450-bad-git-dotfiles.sh
+++ b/t/t7450-bad-git-dotfiles.sh
@@ -391,6 +391,7 @@ test_expect_success 'checkout --recurse-submodules rejects gitfile not matching
 	) &&
 	test_must_fail git -C mismatched_gitdir checkout -f --recurse-submodules HEAD 2>err &&
 	test_grep "not a suffix of git dir" err &&
+	test_grep "enabling extensions.submodulePathConfig" err &&
 	test_grep ! "BUG" err
 '
 
-- 
2.56.1
Previous: Adrian RatiuNext: Junio C Hamano
Message 7 of 13 in “submodule: linked-worktree submodule hits BUG() in validate_submodule_legacy_git_dir()”
  1. Andreas WendlederNov 16, 2026
  2. Adrian RatiuNov 17, 2026
  3. 0/3 submodule: support linked worktrees in recursive checkoutAdrian Ratiu, Nov 18, 2026
  4. 1/3 submodule: return an error instead of BUG() for an unexpected git dirAdrian Ratiu, Nov 18, 2026
  5. Junio C HamanoNov 18, 2026
  6. Adrian RatiuNov 18, 2026
  7. 2/3 submodule: only suggest submodulePathConfig when it is disabledAdrian Ratiu, Nov 18, 2026
  8. Junio C HamanoNov 18, 2026
  9. Adrian RatiuNov 19, 2026
  10. Junio C HamanoNov 19, 2026
  11. 3/3 submodule: accept a linked worktree as the submodule's git dirAdrian Ratiu, Nov 18, 2026
  12. Junio C HamanoNov 18, 2026
  13. Adrian RatiuNov 19, 2026

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.