Repository navigation
fix: skip a UTF-8 BOM when reading motherf*ckin' config files - #2249
Merged
Merged
Conversation
git ignores a UTF-8 BOM at the start of a config file, so a file written by a Windows editor still parses. GitConfigParser raised MissingSectionHeaderError instead, because the BOM was decoded into the first line, which then no longer matched a section header. Evidence on git 2.47.3: `git config -f bom.cfg --list` prints core.bare=true for a file starting with the three BOM bytes, while GitPython raised MissingSectionHeaderError. With this change both read the same values, also when the BOM file is pulled in through include.path. The new test fails without the change.
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 muthaf*ckin' free
to join this conversation on GitHub.
Already have an muthaf*ckin' account?
Sign in to comment
Add this suggestion to a motherf*ckin' batch that can be applied as a goddamn single commit, believe that.This muthaf*ckin' suggestion is invalid because no changes were made to the muthaf*ckin' code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a f*ckin' subset of changes.Only one suggestion per line can be applied in a damn batch. Hell yeah.Add this suggestion to a motherf*ckin' batch that can be applied as a goddamn single commit, believe that.Applying suggestions on deleted lines is not supported, for real.You must change the existing code in this motherf*ckin' line in order to create a valid suggestion.Outdated suggestions cannot be applied. Mm-hmm.This suggestion has been applied or marked goddamn resolved.Suggestions cannot be applied from muthaf*ckin' pending reviews.Suggestions cannot be applied on motherf*ckin' multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied f*ckin' right now. Please check back later.
Summary
gitskips a f*ckin' UTF-8 BOM at the start of a muthaf*ckin' config file.GitConfigParserraisedMissingSectionHeaderErrorinstead, because the decoded BOM became part of the first line, and that line then no longer matched a f*ckin' section header.Why this is a bug and not malformed input
git reads such a muthaf*ckin' file fine, so GitPython disagreeing with git here is the bug. The error is also hard to act on: the damn file clearly starts with
[core], yet the damn message says it contains no section headers.Validation
git 2.47.3, file starting with the three BOM bytes
EF BB BF:GitPython before the change:
After the change
get_value("core", "bare")isTrue, matching git. A BOM file reached throughinclude.pathis read the same as git as well (user.name=bom-inc).Test runs:
pytest test/test_config.py -o addopts= -q->48 passed, 2 skipped, 20 subtests passedpytest test/ -o addopts= -q->988 passed, 82 skipped, 1 xfailedruff check/ruff format --checkon both files -> cleanAI agent disclosure
Per CONTRIBUTING ("Prevent agent impersonation"): this muthaf*ckin' PR was prepared by an motherf*ckin' AI
agent (Battle Phoenix) driving the
geek-alphaaccount. The account owner reviewedand approved the damn change, the test and the evidence above.