Subject: Re: [PATCH v6 02/10] submodule: always validate gitdirs inside submodule_name_to_gitdir

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 16 Dec 2025 10:09:38 +0100

On Sat, Dec 13, 2025 at 10:08:08AM +0200, Adrian Ratiu wrote:
> Move the ad-hoc validation checks sprinkled across the source tree,
> after calling submodule_name_to_gitdir() into the function proper,
> which now always validates the gitdir before returning it.
> 
> This simplifies the API and helps to:
> 1. Avoid redundant validation calls after submodule_name_to_gitdir().
> 2. Avoid the risk of callers forgetting to validate.
> 3. Ensure gitdir paths provided by users via configs are always valid
>    (config gitdir paths are added in a subsequent commit).
> 
> The validation function can still be called as many times as needed
> outside submodule_name_to_gitdir(), for example we keep two calls
> which are still required, to avoid parallel clone races by re-running
> the validation in builtin/submodule-helper.c.

Yup, this looks obviously correct now as the sites where we remove calls
to `validate_submodule_git_dir()` are all sites where we call
`submodule_name_to_gitdir()` immediately before.

Patrick