Re: [PATCH 2/3] submodule: only suggest submodulePathConfig when it is disabled
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 18, 2026, 19:28 UTC
- Message-ID
- <xmqqzev63pnh.fsf@gitster.g>
- In-Reply-To
- <20261118163249.1693361-3-adrian.ratiu@collabora.com>
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
Show 7 quoted lines
> 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.
Show 27 quoted lines
> 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.