]> git.ipfire.org Git - thirdparty/git.git/commit
submodule: always validate gitdirs inside submodule_name_to_gitdir
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Mon, 12 Jan 2026 18:46:23 +0000 (20:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Jan 2026 19:56:55 +0000 (11:56 -0800)
commit05a1cdb5255b2b438e66bdaa91b7b2ce75fbe71b
tree5fbb979a59dde6dc7c5db28f50aee21d5103d573
parentb60f7d890dee571069f9c3c6d44ecaed5c34fa39
submodule: always validate gitdirs inside submodule_name_to_gitdir

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.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
submodule.c