fix: match Git config names case-insensitively (#2240) · gitpython-developers/GitPython@fb8a0bd · GitHub
Skip to content

Commit fb8a0bd

Browse files
Byroncodex
andcommitted
fix: match Git config names case-insensitively (#2240)
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>
1 parent 696e1cb commit fb8a0bd

3 files changed

Lines changed: 146 additions & 19 deletions

File tree

git/config.py

Lines changed: 44 additions & 16 deletions

git/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def exists(self) -> bool:
632632
def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Iterator["Remote"]:
633633
""":return: Iterator yielding :class:`Remote` objects of the given repository"""
634634
for section in repo.config_reader("repository").sections():
635-
if not section.startswith("remote "):
635+
if not section.lower().startswith("remote "):
636636
continue
637637
lbound = section.find('"')
638638
rbound = section.rfind('"')

test/test_config.py

Lines changed: 101 additions & 2 deletions

0 commit comments

Comments
 (0)