From: Adrian Ratiu <adrian.ratiu@collabora.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Andreas Wendleder <gonsolo@gmail.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Patrick Steinhardt <ps@pks.im>
Subject: Re: [PATCH 2/3] submodule: only suggest submodulePathConfig when it is disabled
Date: Thu, 19 Nov 2026 13:46:53 +0200 [thread overview]
Message-ID: <871p8hjb6a.fsf@collabora.com> (raw)
In-Reply-To: <xmqqzev63pnh.fsf@gitster.g>
On Wed, 18 Nov 2026, Junio C Hamano <gitster@pobox.com> wrote:
> Adrian Ratiu <adrian.ratiu@collabora.com> writes:
>
>> When a recursive checkout refuses to use a submodule's git dir, the
>> error message ends with:
>>
>> Enabling extensions.submodulePathConfig should fix this.
>>
>> This is printed even when the extension is already enabled, which is
>> confusing: the user is told to turn on something that is already on.
>
> The motivation sounds sensible.
>
>> Move the suggestion into a separate hint, as submodule_name_to_gitdir()
>> already does, and only show it when the extension is disabled.
>
> Hmph, but submodule_name_to_gitdir() does
>
> /* validate because users might have modified the config */
> if (validate_submodule_git_dir(buf->buf, submodule_name)) {
> advise(_("enabling extensions.submodulePathConfig might fix the "
> "following error, if it's not already enabled."));
> die(_("refusing to create/use '%s' in another submodule's "
> " git dir."), buf->buf);
> }
>
> which does not really check if it is enabled; it just hedges the
> message by using "might fix ... if it's not" and lets the users do
> the work themselves, which is not necessarily a bad approach to take
> to simplify our job.
>
> Similarly, builtin/submodule--helper.c:clone_submodule(), which is
> another caller of validate_submodule_git_dir(), has an unconditional
> "Enabling ... should fix this" message, which we may want to give a
> similar treatment.
Ack, I mis-remembered that we already checked the extension.
Happy to reword as you suggested, but for v2 I'd also like to explore
dropping the "hedge" and actually check in all three places, it should
be a trivial helper which reads repository_format_submodule_path_cfg.
>> Reported-by: Andreas Wendleder <gonsolo@gmail.com>
>> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
>> ---
>> submodule.c | 10 ++++++----
>> t/t7425-submodule-gitdir-path-extension.sh | 14 ++++++++++++++
>> t/t7450-bad-git-dotfiles.sh | 1 +
>> 3 files changed, 21 insertions(+), 4 deletions(-)
>>
>> diff --git a/submodule.c b/submodule.c
>> index d00d820d42..64cd8005f7 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -2171,11 +2171,13 @@ int submodule_move_head(const char *path, const char *super_prefix,
>>
>> free(dotgit);
>> if (validate_submodule_git_dir(git_dir,
>> - sub->name) < 0)
>> + sub->name) < 0) {
>> + if (!the_repository->repository_format_submodule_path_cfg)
>> + advise(_("enabling extensions.submodulePathConfig "
>> + "might fix the following error."));
>> die(_("refusing to create/use '%s' in "
>> - "another submodule's git dir. "
>> - "Enabling extensions.submodulePathConfig "
>> - "should fix this."), git_dir);
>> + "another submodule's git dir."), git_dir);
>> + }
>
> It is not exactly a new issue, but this makes an already too deeply
> nested block even worse. I wonder if the entire "if not dry-run, do
> these" block should be moved to a private helper function to make it
> a bit easier to read.
Sure, I can add a helper here as well in v2. Thanks!
next prev parent reply other threads:[~2026-11-19 11:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 22:51 submodule: linked-worktree submodule hits BUG() in validate_submodule_legacy_git_dir() Andreas Wendleder
2026-11-17 17:45 ` Adrian Ratiu
2026-11-18 16:32 ` [PATCH 0/3] submodule: support linked worktrees in recursive checkout Adrian Ratiu
2026-11-18 16:32 ` [PATCH 1/3] submodule: return an error instead of BUG() for an unexpected git dir Adrian Ratiu
2026-11-18 19:15 ` Junio C Hamano
2026-11-18 19:33 ` Adrian Ratiu
2026-11-18 16:32 ` [PATCH 2/3] submodule: only suggest submodulePathConfig when it is disabled Adrian Ratiu
2026-11-18 19:28 ` Junio C Hamano
2026-11-19 11:46 ` Adrian Ratiu [this message]
2026-11-18 16:32 ` [PATCH 3/3] submodule: accept a linked worktree as the submodule's git dir Adrian Ratiu
2026-11-18 19:52 ` Junio C Hamano
2026-11-19 12:19 ` Adrian Ratiu
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=871p8hjb6a.fsf@collabora.com \
--to=adrian.ratiu@collabora.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gonsolo@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/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