Git development
 help / color / mirror / Atom feed
From: "Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "D. Ben Knoble" <ben.knoble@gmail.com>,
	Alessio Attilio <attilio.alessio@protonmail.com>,
	Alessio Attilio <attilio.alessio@protonmail.com>
Subject: [PATCH v5 4/4] status: test submodule URL warnings
Date: Tue, 01 Dec 2026 21:08:58 +0000	[thread overview]
Message-ID: <ec282a2a6c40eb728c861c7f5b3eaf17ef56a64f.1796159338.git.gitgitgadget@gmail.com> (raw)
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

      parent reply	other threads:[~2026-12-01 21:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 10:21 [PATCH] status: warn about stale submodule URLs Alessio Attilio via GitGitGadget
2026-11-27 13:41 ` D. Ben Knoble
2026-11-27 16:16 ` [PATCH v2 0/2] status: report when submodule URLs are out of sync Alessio Attilio via GitGitGadget
2026-11-27 16:16   ` [PATCH v2 1/2] submodule: prepare URL helpers for reuse Alessio Attilio via GitGitGadget
2026-11-27 16:16   ` [PATCH v2 2/2] status: warn about stale submodule URLs Alessio Attilio via GitGitGadget
2026-11-27 18:11     ` Junio C Hamano
2026-11-27 20:35       ` ATTILIO ALESSIO
2026-11-30 15:46       ` D. Ben Knoble
2026-11-27 21:27 ` [PATCH v3 0/2] status: report when submodule URLs are out of sync Alessio Attilio via GitGitGadget
2026-11-27 21:27   ` [PATCH v3 1/2] submodule: prepare URL helpers for reuse Alessio Attilio via GitGitGadget
2026-11-28  3:38     ` Junio C Hamano
2026-11-27 21:27   ` [PATCH v3 2/2] status: warn about stale submodule URLs Alessio Attilio via GitGitGadget
2026-11-28  4:08     ` Junio C Hamano
2026-11-28  4:19   ` [PATCH v3 0/2] status: report when submodule URLs are out of sync Junio C Hamano
2026-11-28 16:53 ` [PATCH v4 0/3] " Alessio Attilio via GitGitGadget
2026-11-28 16:53   ` [PATCH v4 1/3] submodule: move URL helpers into submodule.c Alessio Attilio via GitGitGadget
2026-11-30 15:54     ` D. Ben Knoble
2026-11-28 16:53   ` [PATCH v4 2/3] submodule: make URL resolution repository-aware Alessio Attilio via GitGitGadget
2026-11-30 15:56     ` D. Ben Knoble
2026-11-28 16:53   ` [PATCH v4 3/3] status: report when submodule URLs are out of sync Alessio Attilio via GitGitGadget
2026-11-29 15:42     ` Junio C Hamano
2026-12-01 21:08 ` [PATCH v5 0/4] " Alessio Attilio via GitGitGadget
2026-12-01 21:08   ` [PATCH v5 1/4] submodule: share repository-aware URL resolution Alessio Attilio via GitGitGadget
2026-12-01 21:08   ` [PATCH v5 2/4] status: warn about submodule URL mismatches Alessio Attilio via GitGitGadget
2026-12-01 21:08   ` [PATCH v5 3/4] status: preserve customized submodule remotes Alessio Attilio via GitGitGadget
2026-12-01 21:08   ` Alessio Attilio via GitGitGadget [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec282a2a6c40eb728c861c7f5b3eaf17ef56a64f.1796159338.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=attilio.alessio@protonmail.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox