From: Junio C Hamano Date: Sat, 28 Nov 2026 04:08:57 GMT Subject: Re: [PATCH v3 2/2] status: warn about stale submodule URLs Message-ID: In-Reply-To: <9dc62830755b06ca2a95d307dd0b593d2a77c536.1795814853.git.gitgitgadget@gmail.com> "Alessio Attilio via GitGitGadget" writes: > 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. > 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. > 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. > +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.