diff options
| author | Adrian Ratiu <adrian.ratiu@collabora.com> | 2026-01-12 20:46:30 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-01-12 11:56:56 -0800 |
| commit | 1685bba838ace8b4e325616ab914a6b01f18547f (patch) | |
| tree | 01a378dc363fc58f03a7564a9b633bfdabe81eda /builtin | |
| parent | 920fbe4d4ee8d4e191d33dde05a16ee0e74bdd44 (diff) | |
| download | git-1685bba838ace8b4e325616ab914a6b01f18547f.tar.xz | |
submodule: fix case-folding gitdir filesystem collisions
Add a new check when extension.submodulePathConfig is enabled, to
detect and prevent case-folding filesystem colisions. When this
new check is triggered, a stricter casefolding aware URI encoding
is used to percent-encode uppercase characters.
By using this check/retry mechanism the uppercase encoding is
only applied when necessary, so case-sensitive filesystems are
not affected.
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/submodule--helper.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 361542d678..746f9fa63c 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -473,7 +473,7 @@ static void create_default_gitdir_config(const char *submodule_name) return; } - /* Case 2: Try URI-safe (RFC3986) encoding first, this fixes nested gitdirs */ + /* Case 2.1: Try URI-safe (RFC3986) encoding first, this fixes nested gitdirs */ strbuf_reset(&gitdir_path); repo_git_path_append(the_repository, &gitdir_path, "modules/"); strbuf_addstr_urlencode(&gitdir_path, submodule_name, is_rfc3986_unreserved); @@ -482,6 +482,30 @@ static void create_default_gitdir_config(const char *submodule_name) return; } + /* Case 2.2: Try extended uppercase URI (RFC3986) encoding, to fix case-folding */ + strbuf_reset(&gitdir_path); + repo_git_path_append(the_repository, &gitdir_path, "modules/"); + strbuf_addstr_urlencode(&gitdir_path, submodule_name, is_casefolding_rfc3986_unreserved); + if (!validate_and_set_submodule_gitdir(&gitdir_path, submodule_name)) + return; + + /* Case 2.3: Try some derived gitdir names, see if one sticks */ + for (char c = '0'; c <= '9'; c++) { + strbuf_reset(&gitdir_path); + repo_git_path_append(the_repository, &gitdir_path, "modules/"); + strbuf_addstr_urlencode(&gitdir_path, submodule_name, is_rfc3986_unreserved); + strbuf_addch(&gitdir_path, c); + if (!validate_and_set_submodule_gitdir(&gitdir_path, submodule_name)) + return; + + strbuf_reset(&gitdir_path); + repo_git_path_append(the_repository, &gitdir_path, "modules/"); + strbuf_addstr_urlencode(&gitdir_path, submodule_name, is_casefolding_rfc3986_unreserved); + strbuf_addch(&gitdir_path, c); + if (!validate_and_set_submodule_gitdir(&gitdir_path, submodule_name)) + return; + } + /* Case 3: nothing worked, error out */ die(_("failed to set a valid default config for 'submodule.%s.gitdir'. " "Please ensure it is set, for example by running something like: " |
