From: Junio C Hamano <gitster@pobox.com>
To: "Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Alessio Attilio <attilio.alessio@protonmail.com>
Subject: Re: [PATCH v4 3/3] status: report when submodule URLs are out of sync
Date: Sun, 29 Nov 2026 07:42:56 -0800 [thread overview]
Message-ID: <xmqqfqwjod8f.fsf@gitster.g> (raw)
In-Reply-To: <619101d5e124115a43faf51c84655b7b99a431dd.1795884822.git.gitgitgadget@gmail.com> (Alessio Attilio via GitGitGadget's message of "Sat, 28 Nov 2026 16:53:42 +0000")
"Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com> writes:
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 36e47e18ed..577b097aa0 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1636,6 +1636,7 @@ struct repository *repo UNUSED)
>
> s.ignore_submodule_arg = ignore_submodule_arg;
> s.status_format = status_format;
> + s.check_submodule_urls = 1;
The hunk header unfortunately is hard to read but this is inside
cmd_status().
Now whichever format wt_status_print() is triggered with, we will show
the submodule changes but only when the top-level command is "git
status".
Good.
> diff --git a/wt-status.c b/wt-status.c
> ...
> +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);
> + if (!repo_config_get_value_multi(&subrepo, key, &remote_urls) &&
> + remote_urls->nr == 1 &&
> + (remote_url = remote_urls->items[0].string)) {
The third condition being a non-NULL check of the value and not a
comparison can easily become confusing. GNU toolchains seem to
encourage putting such a "var = value" assignment that is also used for
a non-NULL/0 check inside an extra pair of parentheses, which is the
convention the above code also uses. Use of the _get_value_ variant and
checking the NULL-ness of .string allows us to cope with a valueless
truth "[remote "frotz"] url;" cleanly.
> +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;
> + }
Do we see a small inconsistency with the repository-aware design from
the previous patch here?
This function takes 'repo' and passes it to repo_submodule_init() and
resolve_submodule_url(), yet is_submodule_populated_gently() inspects
"%s/.git" relative to the current working directory rather than the
'.worktree' member of 'repo'.
That may be harmless today because cmd_status() runs with NEED_WORK_TREE
and repo == the_repository, so we are always at the worktree root. It
might be worth a comment near the call to is_submodule_populated_gently()
though.
> +static void wt_status_check_submodule_urls(struct wt_status *s)
> +{
> + int i;
> +
> + if (s->ignore_submodule_arg &&
> + !strcmp(s->ignore_submodule_arg, "all"))
> + return;
> +
> + if (is_gitmodules_unmerged(s->repo->index))
> + return;
> +
> + for (i = 0; i < s->repo->index->cache_nr; i++) {
> + struct cache_entry *ce = s->repo->index->cache[i];
Because cmd_status() sets '.command_requires_full_index' to 0, you need
to be careful when iterating '.cache' directly like the above loop when
sparse-index is in effect.
In sparse-index.c, convert_to_sparse_rec() refuses to collapse any
directory containing S_ISGITLINK entries, so I _think_ gitlinks remain
visible even in a sparse index, but please double check.
Overall, this iteration was a very pleasant read.
Thanks for working on it.
prev parent reply other threads:[~2026-11-29 15:42 UTC|newest]
Thread overview: 21+ 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 [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=xmqqfqwjod8f.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=attilio.alessio@protonmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
/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