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

[PATCH v5 4/4] status: test submodule URL warnings

From
AGAlessio Attilio via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 1, 2026, 21:08 UTC
Message-ID
<ec282a2a6c40eb728c861c7f5b3eaf17ef56a64f.1796159338.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2509.v5.git.git.1796159338.gitgitgadget@gmail.com>
From: Alessio Attilio <attilio.alessio@protonmail.com>

Exercise the warning and sync advice across output formats, relative URLs, pathspecs, ignored submodules, populated remotes, and commit status. Document when the warning appears and how to clear the mismatch.

Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
 Documentation/git-status.adoc |  12 ++++
 t/t7508-status.sh             | 121 ++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)
diff --git a/Documentation/git-status.adoc b/Documentation/git-status.adoc
index 9acca52bfb..6e997fbef0 100644
--- a/Documentation/git-status.adoc
+++ b/Documentation/git-status.adoc
@@ -22,6 +22,18 @@ are what you _would_ commit by running `git commit`; the second and
 third are what you _could_ commit by running `git add` before running
 `git commit`.
 
+When a submodule's URL in `.gitmodules` differs from the URL cached in
+`.git/config`, `git status` warns that `git submodule sync` can update the
+cached URL. For a populated submodule, the warning is suppressed when its
+default remote URL differs from both URLs, since syncing would overwrite a
+customized remote. Relative URLs are resolved as `git submodule sync`
+resolves them.
+
+The warning is written to standard error in long, short, and porcelain
+formats, and is limited to submodules matched by the pathspec. It is
+suppressed when `--ignore-submodules` or `--ignore-submodules=all` is
+specified.
+
 OPTIONS
 -------
 
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index e10c961268..ff03c6a96e 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -921,6 +921,127 @@ test_expect_success 'setup status submodule summary' '
 	git add sm
 '
 
+test_expect_success 'status reports submodule URL mismatch' '
+	test_when_finished "rm -rf url-test" &&
+	test_create_repo url-test/source &&
+	test_commit -C url-test/source initial &&
+	test_create_repo url-test/super &&
+	git -C url-test/super -c protocol.file.allow=always \
+		submodule add "$PWD/url-test/source" module &&
+	git -C url-test/super commit -m "add submodule" &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super config -f .gitmodules submodule.module.url \
+		"$PWD/url-test/updated-source" &&
+	git -C url-test/super status --porcelain >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	cat >url-test/editor <<\EOF &&
+#!/bin/sh
+echo "status test commit" >"$1"
+EOF
+	chmod +x url-test/editor &&
+	echo staged >url-test/super/staged &&
+	git -C url-test/super add staged &&
+	test_set_editor "$PWD/url-test/editor" &&
+	git -C url-test/super commit >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super status --short >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super status --porcelain=v2 >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super status --ignore-submodules=none >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super status --ignore-submodules=dirty >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super status --ignore-submodules=all >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super status --ignore-submodules >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super status -- .gitmodules >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super status -- module >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	test_grep "git submodule sync" url-test/err &&
+	git -C url-test/super submodule sync &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super remote add origin ../source-parent &&
+	git -C url-test/super config -f .gitmodules submodule.module.url \
+		../relative-source &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super submodule sync &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super config -f .gitmodules submodule.module.url \
+		../another-relative-source &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super submodule sync &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super/module config remote.origin.url \
+		"$PWD/url-test/fork" &&
+	git -C url-test/super config -f .gitmodules submodule.module.url \
+		../fork-source &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super config -f .gitmodules submodule.module.url \
+		"$PWD/url-test/upstream-source" &&
+	git -C url-test/super submodule sync &&
+	git -C url-test/super/module config remote.upstream.url \
+		"$PWD/url-test/upstream-source" &&
+	git -C url-test/super/module config remote.origin.url \
+		"$PWD/url-test/fork" &&
+	git -C url-test/super config submodule.module.url \
+		"$PWD/url-test/stale-source" &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/super/module config --add remote.origin.url \
+		"$PWD/url-test/another-fork" &&
+	git -C url-test/super config -f .gitmodules submodule.module.url \
+		../another-fork-source &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/super/module config --unset-all remote.origin.url &&
+	git -C url-test/super config --add submodule.module.url \
+		"$PWD/url-test/another-configured-source" &&
+	git -C url-test/super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err
+'
+
+test_expect_success 'status compares relative submodule URLs only once' '
+	test_when_finished "rm -rf url-test" &&
+	test_create_repo url-test/relative-source &&
+	test_commit -C url-test/relative-source initial &&
+	test_create_repo url-test/relative-super &&
+	git -C url-test/relative-super -c protocol.file.allow=always \
+		submodule add "$PWD/url-test/relative-source" module &&
+	git -C url-test/relative-super commit -m "add submodule" &&
+	git -C url-test/relative-super remote add origin ../a/b &&
+	git -C url-test/relative-super config -f .gitmodules \
+		submodule.module.url ../mod1 &&
+	git -C url-test/relative-super submodule sync &&
+	git -C url-test/relative-super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/relative-super config -f .gitmodules \
+		submodule.module.url ../mod2 &&
+	git -C url-test/relative-super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err &&
+	git -C url-test/relative-super remote set-url origin a/b &&
+	git -C url-test/relative-super config -f .gitmodules \
+		submodule.module.url ../mod1 &&
+	git -C url-test/relative-super submodule sync &&
+	git -C url-test/relative-super status >url-test/actual 2>url-test/err &&
+	test_must_be_empty url-test/err &&
+	git -C url-test/relative-super config -f .gitmodules \
+		submodule.module.url ../mod2 &&
+	git -C url-test/relative-super status >url-test/actual 2>url-test/err &&
+	test_grep "module.*different URL" url-test/err
+'
+
 test_expect_success 'status submodule summary is disabled by default' '
 	cat >expect <<EOF &&
 On branch main
-- 
gitgitgadget
Previous: Alessio Attilio via GitGitGadget
Message 26 of 26 in “status: warn about stale submodule URLs”
  1. status: warn about stale submodule URLsAlessio Attilio via GitGitGadget, Nov 27, 2026
  2. D. Ben KnobleNov 27, 2026
  3. 0/2 status: report when submodule URLs are out of syncAlessio Attilio via GitGitGadget, Nov 27, 2026
  4. 1/2 submodule: prepare URL helpers for reuseAlessio Attilio via GitGitGadget, Nov 27, 2026
  5. 2/2 status: warn about stale submodule URLsAlessio Attilio via GitGitGadget, Nov 27, 2026
  6. Junio C HamanoNov 27, 2026
  7. ATTILIO ALESSIONov 27, 2026
  8. D. Ben KnobleNov 30, 2026
  9. 0/2 status: report when submodule URLs are out of syncAlessio Attilio via GitGitGadget, Nov 27, 2026
  10. 1/2 submodule: prepare URL helpers for reuseAlessio Attilio via GitGitGadget, Nov 27, 2026
  11. Junio C HamanoNov 28, 2026
  12. 2/2 status: warn about stale submodule URLsAlessio Attilio via GitGitGadget, Nov 27, 2026
  13. Junio C HamanoNov 28, 2026
  14. Junio C HamanoNov 28, 2026
  15. 0/3 status: report when submodule URLs are out of syncAlessio Attilio via GitGitGadget, Nov 28, 2026
  16. 1/3 submodule: move URL helpers into submodule.cAlessio Attilio via GitGitGadget, Nov 28, 2026
  17. D. Ben KnobleNov 30, 2026
  18. 2/3 submodule: make URL resolution repository-awareAlessio Attilio via GitGitGadget, Nov 28, 2026
  19. D. Ben KnobleNov 30, 2026
  20. 3/3 status: report when submodule URLs are out of syncAlessio Attilio via GitGitGadget, Nov 28, 2026
  21. Junio C HamanoNov 29, 2026
  22. 0/4 status: report when submodule URLs are out of syncAlessio Attilio via GitGitGadget, Dec 1, 2026
  23. 1/4 submodule: share repository-aware URL resolutionAlessio Attilio via GitGitGadget, Dec 1, 2026
  24. 2/4 status: warn about submodule URL mismatchesAlessio Attilio via GitGitGadget, Dec 1, 2026
  25. 3/4 status: preserve customized submodule remotesAlessio Attilio via GitGitGadget, Dec 1, 2026
  26. 4/4 status: test submodule URL warningsAlessio Attilio via GitGitGadget, Dec 1, 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.