Subject: Re: [PATCH v3 4/5] submodule: encode gitdir paths to avoid conflicts

From: Junio C Hamano <[email-masked]>
Date: Tue, 07 Oct 2025 12:55:26 -0700

Adrian Ratiu <[email-masked]> writes:

> The problem becomes how to detect (1) and (2), for example: a 
> specific name is filesystem-friendly or is case-folding happening 
> or not?
>
> (ext4 for example can be mounted with casefolding on/off)

core.ignorecase is dynamically probed upon reposiory creation, if I
am not mistaken.

But other things like "I have this name, transformed to avoid
slashes and other problematic letters and the result got this long,
would it fit or would I get ENAMETOOLONG?", I think the code may
have to be prepared to try-fail-adjust-retry.  We come up with a
proposed "munged" name, try to mkdir() with that name, see that it
fails with ENAMETOOLONG, shorten the munged name and retry.  And we
ensure the name we propose is unique among submodule.<name>.gitdirpath
paths in use, then hopefully we find a good name that fits, recognisable
by human, acceptable by the filesystem and unique among submodules.

Even without consulting core.ignorecase, I suspect that the code can
do a similar try-fail-adjust-retry for case-insensitive or NFC/NFD
clashes.  We try to mkdir() with a munged name, and if we get
EEXISTS and submodule.<name>.gitdirpath would not have the path we
tried already registered, then we are seeing another path that is
not byte-for-byte identical to ours conflicting, so we can adjust
ours and retry, for example.