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

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

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Nov 30, 2026, 15:46 UTC
Message-ID
<CALnO6CBdBZYTHpRRtdctoHDdXiDs-PBuNrxoW9SULk3-WZJC6A@mail.gmail.com>
In-Reply-To
<xmqqecc69maa.fsf@gitster.g>
On Fri, Nov 27, 2026 at 1:12 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
>
> "Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Alessio Attilio <attilio.alessio@protonmail.com>
> >
> > When a submodule URL changes in .gitmodules, the cached
> > submodule.<name>.url in the superproject config can stay stale. Warn
> > in git status so users can run git submodule sync before a later
> > submodule operation uses the outdated URL.
> >
> > Resolve relative URLs using the same paths as git submodule sync.
> > Avoid warning when the submodule remote indicates a local
> > customization that sync would overwrite.
> >
> > Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
> > ---
>
> Surfacing stale submodule configuration in "git status" is a very useful
> improvement.  Like Ben noted, splitting the helper extraction out into a
> preparatory commit made the series easier to follow.
>
> It would help to explain in the proposed log message why three URLs are
> compared and under what condition, and which status formats emit the
> warning.

Indeed, I was minded of "reviewing is a discussion" (https://lore.kernel.org/git/20261022211404.380904-3-gitster@pobox.com/) and "good manners" being to discuss before sending off v2 (https://lore.kernel.org/git/xmqqmrquetqq.fsf@gitster.g/).

Show 14 quoted lines
> > +             up_path = get_submodule_up_path(path);
> > +             config_remote_url = resolve_submodule_url(repo, config_url,
> > +                                                       up_path, 1);
> > +             gitmodules_remote_url = resolve_submodule_url(repo, gitmodules_url,
> > +                                                           up_path, 1);
> > +             /*
> > +              * The submodule's remote URL may be a local fork. If it matches
> > +              * neither the old cached URL nor the new .gitmodules URL, leave it
> > +              * alone; syncing would overwrite that customization.
> > +              */
> > +             ret = strcmp(remote_url, config_remote_url) != 0 &&
> > +                     strcmp(remote_url, gitmodules_remote_url) != 0;
>
> Renaming of new/old may address one of the points of confusion Ben had.

I think so: it now seems that "remote_url" is the one from the submodule (e.g., git -C sub remote -v), config_*url is the cached URL, and gitmodules_*url is, well, the .gitmodules URL.

Show 14 quoted lines
> When the superproject's own default remote URL is relative, doesn't
> this logic break?
>
> In wt_status_check_submodule_urls() we see below, 'gitmodules_url' was
> already computed by resolving sub->url against the superproject's
> default remote with 'up_path' set to NULL.  Likewise, 'config_url' from
> submodule.<name>.url in .git/config was already resolved once with
> 'up_path' set to NULL when init_submodule() or sync_submodule() wrote
> it.
>
> Passing already-resolved URLs into resolve_submodule_url() again smells
> fishy.  There are a few ways I can think of that this can break.  I may
> be misreading the code flow, and these may be no issue, or there may be
> other issues.

I mentioned the double-resolution in passing before, thanks for making the potential issues (which I only thought of for performance) more explicit.

Show 37 quoted lines
>  * When the superproject has "remote.origin.url = a/b" (relative without
>    "./" or "../") and .gitmodules has "../mod1", sync_submodule() stores
>    "a/mod1" in submodule.module.url and "../a/mod1" in the submodule's
>    remote.origin.url.
>
>    submodule_has_custom_remote_url() calls resolve_submodule_url() on
>    "a/mod1".  It hits the early return without prepending 'up_path', so
>    'config_remote_url' is "a/mod1" instead of "../a/mod1" and fails to
>    match.
>
>  * When the superproject has "remote.origin.url = ../a/b", .gitmodules
>    initially has "submodule.module.url = ../mod1", and the user runs
>    "git submodule sync".  In sync_submodule(), relative_url() stores
>    "../a/mod1" in submodule.module.url and "../../a/mod1" in the
>    submodule's remote.origin.url.
>
>    If submodule.module.url in .gitmodules then changes to "../mod2",
>    wt_status_check_submodule_urls() sets 'gitmodules_remote_url' to
>    "../a/mod2".  Inside submodule_has_custom_remote_url(), both
>    "../a/mod1" and "../a/mod2" still start with "../", so
>    resolve_submodule_url() resolves them a second time against "../a/b".
>
>    Wouldn't the result be "../../a/a/mod1" and "../../a/a/mod2" in such
>    a case?
>
>    Neither matches "../../a/mod1", so submodule_has_custom_remote_url()
>    returns 1 and suppresses the warning even though the submodule remote
>    was never customized.  The new test in t7508 used "../source-parent"
>    with only one path component after "..", where the second resolution
>    happened to be a no-op, so it may not have noticed the breakage.
>
> In order to match what sync_submodule() does, 'gitmodules_remote_url'
> should be computed from the raw 'sub->url', not from 'gitmodules_url',
> no?  For 'config_remote_url', we do not want to run relative_url() again
> on 'config_url', I think.  You only need to prepend 'up_path', or
> something, no?  I didn't think this one through, so take it with a huge
> grain of salt.

Thanks, Ben

Previous: ATTILIO ALESSIONext: Alessio Attilio via GitGitGadget
Message 8 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.