Re: [PATCH v3 5/5] submodule: error out if gitdir name is too long
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 7, 2025, 15:58 UTC
- Message-ID
- <xmqqqzveln5j.fsf@gitster.g>
- In-Reply-To
- <87jz173tih.fsf@collabora.com>
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
> IIRC the consensus was to avoid keeping such a mapping due to > complexity, risk of desynchronizing with the filesystem layout and > so on, so simple rules like the above, or even a simple hash_name > might be better (see below).
I do not quite see a merit in the above argument.
You have submodule.<name>.gitdir that you need to make sure your "risk of desynchronizing" is managed anyway. By making sure name-to-directory always goes through the single mapping, you reduce the complexity and concentrate the choice of the path to a single place, i.e. where it is assigned by munging the name and registered to the mapping.
Show 5 quoted lines
> Someone suggested we use something like .git/modules/<hash>_<name> > when the extension is enabled, so we have a simple, unique and > recognizable pattern. > > What do you think of that?
If there are letters in <name> that you cannot use there (e.g., slash, or perhaps <name> is overly long), you have to munge the <name> part in <hash>_<name> in order to fit the filesystem constraints. And prefixing random string "<hash>_" would be one way to make sure two <name>s that happen to collide after munging can still be differentiated. So I have no problem with prefixing or suffixing, but I do not think that syntax alone is sufficient to solve other issues that come from the fact that some names are not filesystem friendly and can collide with names of other submodules.
Thanks.