Re: [PATCH v2 06/10] submodule: encode gitdir paths to avoid conflicts
On Mon, Sep 08, 2025 at 05:01:13PM +0300, Adrian Ratiu wrote:
> diff --git a/submodule.c b/submodule.c
> index bf78636195..8e0fd077db 100644
> --- a/submodule.c
> +++ b/submodule.c
Show 44 quoted lines
> @@ -2588,30 +2593,26 @@ int submodule_to_gitdir(struct repository *repo,
> return ret;
> }
>
> +static void strbuf_addstr_case_encode(struct strbuf *dst, const char *src)
> +{
> + for (; *src; src++) {
> + unsigned char c = *src;
> + if (c >= 'A' && c <= 'Z') {
> + strbuf_addch(dst, '_');
> + strbuf_addch(dst, c - 'A' + 'a');
> + } else {
> + strbuf_addch(dst, c);
> + }
> + }
> +}
> +
> void submodule_name_to_gitdir(struct strbuf *buf, struct repository *r,
> const char *submodule_name)
> {
> - /*
> - * NEEDSWORK: The current way of mapping a submodule's name to
> - * its location in .git/modules/ has problems with some naming
> - * schemes. For example, if a submodule is named "foo" and
> - * another is named "foo/bar" (whether present in the same
> - * superproject commit or not - the problem will arise if both
> - * superproject commits have been checked out at any point in
> - * time), or if two submodule names only have different cases in
> - * a case-insensitive filesystem.
> - *
> - * There are several solutions, including encoding the path in
> - * some way, introducing a submodule.<name>.gitdir config in
> - * .git/config (not .gitmodules) that allows overriding what the
> - * gitdir of a submodule would be (and teach Git, upon noticing
> - * a clash, to automatically determine a non-clashing name and
> - * to write such a config), or introducing a
> - * submodule.<name>.gitdir config in .gitmodules that repo
> - * administrators can explicitly set. Nothing has been decided,
> - * so for now, just append the name at the end of the path.
> - */
> + struct strbuf encoded_sub_name = STRBUF_INIT, tmp = STRBUF_INIT;
> + size_t base_len, encoded_len;
> char *gitdir_path, *key;
> + long name_max;Some of these new variables are not used or are only written:
submodule.c: In function ‘submodule_name_to_gitdir’:
submodule.c:2615:14: error: unused variable ‘name_max’ [-Werror=unused-variable]
2615 | long name_max;
| ^~~~~~~~
submodule.c:2613:26: error: unused variable ‘encoded_len’ [-Werror=unused-variable]
2613 | size_t base_len, encoded_len;
| ^~~~~~~~~~~
submodule.c:2613:16: error: variable ‘base_len’ set but not used [-Werror=unused-but-set-variable]
2613 | size_t base_len, encoded_len;
| ^~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:2815: submodule.o] Error 1