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

Re: [PATCH v3 2/2] status: warn about stale submodule URLs

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 28, 2026, 04:08 UTC
Message-ID
<xmqqv75hy4va.fsf@gitster.g>
In-Reply-To
<9dc62830755b06ca2a95d307dd0b593d2a77c536.1795814853.git.gitgitgadget@gmail.com>
"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> Resolve relative URLs using the same paths as git submodule sync, and
> do not resolve the already-resolved cached URL a second time. Emit the
> warning on standard error for long, short, and porcelain status output,
> limited to submodules matched by the pathspec. Do not emit it when
> --ignore-submodules is given or when the wt-status machinery is used by
> another command.

The three-URL check now avoids double-resolving config_url and gitmodules_url when the superproject remote URL is relative, and switches from the get_value() config readers to the get_string() family.

The check at the beginning of wt_status_check_submodule_urls() has been replaced with different logic, but I thought that we agreed to move the check to the caller, wt_status_print(), to avoid calling this new helper? There also is a glaring bug in the updated logic for the "--ignore-submodules" check.

Other than these, the issues in the remainder of the patch I saw in an earlier round got much better.

Show 14 quoted lines
> diff --git a/submodule.c b/submodule.c
> index 3eab799f1f..24775b21b7 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -296,9 +296,13 @@ char *resolve_submodule_url(struct repository *repo, const char *rel_url,
>  			    const char *up_path, int quiet)
>  {
>  	char *remoteurl, *resolved_url;
> -	const char *remote = repo_default_remote(repo);
> +	const char *remote;
>  	struct strbuf remotesb = STRBUF_INIT;
>  
> +	if (!starts_with_dot_dot_slash(rel_url) && !starts_with_dot_slash(rel_url))
> +		return xstrdup(rel_url);

It would make resolve_submodule_url() self-contained if you moved this early return into the preparatory patch (the one you will split out of [1/2] for the "repository aware" step). It would allow callers in builtin/submodule--helper.c to drop duplicate checks if desired, too.

Also, starts_with_dot_dot_slash() assumes 'rel_url' is non-NULL; wt_status_check_submodule_urls() checks sub->url first, so current callers are safe, though an explicit NULL guard or doc comment in submodule.h may be worth considering to prevent future surprises.

Show 32 quoted lines
> diff --git a/wt-status.c b/wt-status.c
> index 238bb48643..5bcbe634df 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -2692,8 +2696,124 @@ static void wt_porcelain_v2_print(struct wt_status *s)
>  	}
>  }
>  
> +static int submodule_has_custom_remote_url(struct repository *repo,
> +					  const char *path,
> +					  const char *gitmodules_url,
> +					  const char *config_url)
> +{
> +	struct repository subrepo = { 0 };
> +	const struct string_list *remote_urls = NULL;
> +	const char *remote;
> +	const char *remote_url;
> +	char *key, *up_path, *config_remote_url, *gitmodules_remote_url;
> +	int error_code, ret = 0;
> +
> +	if (!is_submodule_populated_gently(path, &error_code))
> +		return 0;
> +
> +	if (repo_submodule_init(&subrepo, repo, path,
> +				null_oid(repo->hash_algo)) < 0) {
> +		repo_clear(&subrepo);
> +		return 0;
> +	}
> +
> +	remote = repo_default_remote(&subrepo);
> +
> +	key = xstrfmt("remote.%s.url", remote);

In builtin/submodule--helper.c, sync_submodule() picks which submodule remote to update by calling get_default_remote_submodule().

That helper checks repo_remote_from_url() against the resolved .gitmodules URL first and falls back to repo_default_remote(&subrepo) only if no remote matches. If a submodule has both a customized 'origin' remote and an 'upstream' remote that matches what .gitmodules has, sync_submodule() updates 'upstream' without touching 'origin', whereas submodule_has_custom_remote_url() checks only 'origin' and suppresses the warning.

Checking only the default remote is reasonable for the common single-remote case, though it is worth keeping this subtle difference in mind.

Show 6 quoted lines
> +static void wt_status_check_submodule_urls(struct wt_status *s)
> +{
> +	int i;
> +
> +	if (!s->check_submodule_urls || s->ignore_submodule_arg)
> +		return;

I do not think checking .ignore_submodule_arg like this helps. It is of type "const char *", so I assume it holds string values like "none" that you will get when

    git status --ignore-submodules=none
is run, right?  You do not want to punt in such a case.

Comparing against wt_longstatus_print() in wt-status.c shows how other status checks handle this:

    if (s->submodule_summary &&
        (!s->ignore_submodule_arg ||
         strcmp(s->ignore_submodule_arg, "all"))) {
Using
    if (!s->check_submodule_urls ||
        (s->ignore_submodule_arg &&
         !strcmp(s->ignore_submodule_arg, "all")))
            return;

here keeps '--ignore-submodules=none' (and =dirty/=untracked) warning as expected, and matches "suppressed when '--ignore-submodules=all' (or bare '--ignore-submodules') is specified" in the docs and commit log.

Previous: Alessio Attilio via GitGitGadgetNext: Junio C Hamano
Message 13 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.