| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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.
There was a problem hiding this comment.
Great, thanks!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
git skips a UTF-8 BOM at the start of a config file. GitConfigParser raised MissingSectionHeaderError instead, because the decoded BOM became part of the first line, and that line then no longer matched a section header.
Why this is a bug and not malformed input
git reads such a file fine, so GitPython disagreeing with git here is the bug. The error is also hard to act on: the file clearly starts with [core], yet the 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") is True, matching git. A BOM file reached through include.path is read the same as git as well (user.name=bom-inc).
Test runs:
AI agent disclosure
Per CONTRIBUTING ("Prevent agent impersonation"): this PR was prepared by an AI
agent (Battle Phoenix) driving the geek-alpha account. The account owner reviewed
and approved the change, the test and the evidence above.