Skip to content

submodule: fix handling of unusual submodule names - #2340

Open
yoichi wants to merge 2 commits into
gitgitgadget:masterfrom
yoichi:handle-unusual-submodule-name
Open

yoichi wants to merge 2 commits into
gitgitgadget:masterfrom
yoichi:handle-unusual-submodule-name

Conversation

@yoichi

@yoichi yoichi commented Nov 29, 2026

Copy link
Copy Markdown

This series fixes issues with unusual submodule names.

The first patch fixes 'git submodule deinit' failing to remove the
configuration section for submodules whose names contain regexp
metacharacters.

The second patch rejects "." as a submodule name in 'git submodule
add'. This avoids a confusing error and prevents an invalid
submodule...gitdir entry from being written to the configuration
when extensions.submodulePathConfig is enabled.

  • [1/2] submodule deinit: handle regexp metacharacters in names
  • [2/2] submodule add: reject "." as submodule name

'git submodule deinit' internally calls 'git config --get-regexp' to
determine whether the configuration section for the submodule should
be removed. Since the submodule name is included directly in the
regular expression, names containing regexp metacharacters may cause
the `submodule.<name>` section to remain in the configuration after
'git submodule deinit'.

Change the arguments passed to the internal 'git config' call to
retrieve matching configuration keys without including the submodule
name in the regular expression.

Signed-off-by: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>
Specifying "." as the submodule name for 'git submodule add' causes
the command to fail with a confusing error:
    fatal: not a git repository: '.git/modules/.'

Additionally, when `extensions.submodulePathConfig` is set to true,
a `submodule...gitdir` entry is written to the configuration.

Reject "." as a submodule name early in 'git submodule add' to avoid
these problems.

Signed-off-by: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>
@yoichi

yoichi commented Nov 29, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 29, 2026

Copy link
Copy Markdown

Submitted as pull.2340.git.1795989773.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2340/yoichi/handle-unusual-submodule-name-v1

To fetch this version to local tag pr-2340/yoichi/handle-unusual-submodule-name-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2340/yoichi/handle-unusual-submodule-name-v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant