Repository navigation
Merge [DEFAULT] into the default section when case-insensitive - #445
Merged
unknwon merged 2 commits intoNov 17, 2026
Merged
Conversation
Contributor
Author
|
The Go workflow is waiting for approval to run. Could a maintainer approve it when convenient? Local Go 1.27.4 race/coverage tests and golangci-lint 2.15.0 pass; the upstream Go/OS matrix is still unverified. |
addSection now lowercases the default section name in case-insensitive files, so the lexer no longer needs to, and no section is stored under the configured name in a different case.
Member
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.
Describe the pull request
With
CaseInsensitive(true)orCaseInsensitiveSections(true), loadingbefore=1\n[DEFAULT]\nafter=2\ncreates separatedefaultandDEFAULTsections. Normal lookup only finds the first, soSection("").Key("after")reads as missing. ExplicitNewSection(DefaultSection)and recreating a deleted default section throughSection(DefaultSection)have the same naming mismatch.Lowercase the configured default name in
addSectionandmissingSection, just as parsing the implicit default section, lookups and deletion already do. This keeps explicit default headers and writes reachable through both the configured name and"". The regression tests cover both insensitive options, custom default names, parsing and write/reload, new and missing sections, non-unique sections, and case-sensitive/key-only controls.Link to the issue: #198 (current-v2 reproduction).
All 16 new insensitive leaf cases fail on
b9a42897a3d258c3c2a207f53bd13756f687dfddand pass with the fix; the compatibility controls pass before and after. On macOS arm64 with Go 1.27.4, fullgo test ./... -race -cover -shuffle=on -count=1passes (95.4% coverage), as dogo vet ./...,go build ./..., golangci-lint 2.15.0, gofmt andgit diff --check. Other Go versions and operating systems were not tested locally.There is a shared
addSectionhunk with #444: its newstoredSectionNamehelper currently preserves the same default-name exception. This PR fixes existing behavior independently of the new copy/rename APIs, and also coversmissingSection.Checklist
AI usage
OpenAI Codex investigated the issue and contribution requirements, wrote the reproduction comment, implemented and reviewed the patch and tests, ran the validation above, and drafted this PR description.