Fix case-insensitive Git config name matching - #2241
Merged
Conversation
Byron
pushed a commit
that referenced
this pull request
Sep 14, 2026
The lint job on PR #2241 failed in the codespell pre-commit hook because the new write-preservation regression used "readded" as a sample value. The same two diagnostics reproduce with codespell 2.4.3 locally. Use "again" in both the assignment and assertion. The value is arbitrary: the regression checks the spelling of a removed and recreated option, so this satisfies lint without changing the behavior under test. Validation: codespell passes for the three PR files; the affected test passes on Python 3.14.7; Ruff lint and formatting pass for test_config.py.
Mostly a rubber-stamp, impl seems sane and tests seem to cover the important bits. <!-- agent --> GitConfigParser required exact section and option spelling, so valid Git configuration such as core.BigName could not be read as CORE.bigname. Differently cased sections and options also stayed separate, causing lookups to miss later values and writers to create duplicate settings. Index the ordered multi-dictionary by normalized names while retaining the first spelling in storage. Lowercase the section/option portion only; quoted subsection names remain case-sensitive. The shared mapping covers the inherited ConfigParser accessors, multivalue reads, and mutations without scanning all stored names. Case variants now merge in read order, and enumeration and write-back use the first spelling for each name. Normalize include section matching and remote discovery as well, while keeping include conditions and remote names case-sensitive. Add regressions for case variants, duplicate values, implicit booleans, quoted subsections, spelling-preserving writes, removal and renaming, included files, and remote discovery. The three new regression tests failed before the fix. Extend the existing setlast check to cover mixed case and clearing the name index. The behavior follows Documentation/config.adoc and the mixed-case and subsection tests in t/t1300-config.sh from the local Git reference at 1630431f326e15fcde608827b5ff38422528eb59. Regression comparisons with git config --get and --get-all used Git 2.50.1 (Apple Git-155). Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <codex@openai.com>
Byron
force-pushed
the
case-insensitive-gitconfig
branch
from
September 14, 2026 04:49
c4beffe to
fb8a0bd
Compare
Byron
marked this pull request as ready for review
September 14, 2026 05:17
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate and critical issues remain in git/config.py.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This pull request makes Git configuration section and option matching case-insensitive while preserving quoted subsection case sensitivity.
Changes:
- Normalizes config lookups and mutations.
- Supports mixed-case include sections and remote discovery.
- Adds regression coverage for reads, writes, includes, remotes, and booleans.
File summaries
| File | Summary |
|---|---|
test/test_config.py |
Adds regression coverage. |
git/remote.py |
Supports mixed-case remote sections. |
git/config.py |
Implements normalized config-name matching. |
Review details
Suppressed comments (1)
git/config.py:217
_keymapis only populated bysetall, but the constructor delegates initial entries toOrderedDictand never rebuilds the index. This matters foritems_all(), which constructs_OMD(self._defaults): copied default entries can remain unindexed, so a default option spelledFooand a section option spelledfooare treated as different keys and case-insensitive enumeration/mutation is lost. Populate the map from the entries loaded by the constructor (while preserving the existing list values).
def __init__(self, *args: Any, **kwargs: Any) -> None:
self._keymap: Dict[str, str] = {}
super().__init__(*args, **kwargs)
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+219
to
+221
| def _key(self, key: str) -> str: | ||
| stored = self._keymap.get(_normalize_name(key), key) | ||
| return stored if super().__contains__(stored) else key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by
Codex GPT-6.Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Fixes #2240.
GitConfigParser now matches section and option names without regard to case, so
get_value("CORE", "bigname")can read[core] BigName = 1. Quoted subsection names remain case-sensitive:remote "Origin"andremote "origin"are distinct.The existing ordered multi-dictionary indexes normalized names while retaining the first spelling for enumeration and write-back. Case variants merge into one setting with values in read order, and reads, additions, updates, removals, and renames share the same matching rules. Include sections and remote discovery also accept mixed-case section names.
Regression coverage checks duplicate values, implicit booleans, subsection case, original spelling, mutations, included files, and remote discovery. The three new regression tests failed before the fix.
Validation:
Git behavior was checked against Git 2.50.1 and the local Git reference at
1630431f326e15fcde608827b5ff38422528eb59, particularlyDocumentation/config.adocand the mixed-case/subsection tests int/t1300-config.sh.Commits:
94a591d4(config matching) andc4beffeb(test value spelling).Each commit received one
codex review --commitattempt. Both attempts failed because the CLI login has expired (HTTP 401), so no Codex review result is available.