JingHao-Leon
marked this pull request as draft
October 19, 2026 11:07
Git decodes the standard escape sequences in unquoted config values, but `GitConfigParser._read` only called `parse_value()` when a value continued onto a following line. A single-line unquoted value therefore kept its escapes literal, so `b = first\nsecond` read back as `first\nsecond` rather than `first<LF>second`. The same value also decoded differently depending only on whether it was wrapped: `b = first\nsecond \` continued onto a second line already went through `parse_value()` and was decoded. The missing decode made writes unsafe. The parsed value held no control character, so the writer's CR/LF/NUL guard did not trigger, and saving an unrelated key emitted a value that git then read differently than before. With the escape decoded, the existing guard rejects the value instead of corrupting the file. A value is decoded only when every backslash in it introduces a known escape. Git rejects an unknown escape outright, so GitPython never had to handle one; it tolerates them instead, which is what keeps a Windows path such as `C:\Users\me` usable. Decoding unconditionally would have broken that: the `\t` of `\Temp\test_foo` would become a tab while the `\U` of `\Users` stayed literal, mangling the path. Guarding on the whole value decodes `a\tb` and `foo\\bar` as git does and leaves the path alone. An existing case in `test_backslash_line_continuation` asserted the undecoded spelling `val\\` for `k = val\\` followed by a newline. Git yields `val\` there, since the second backslash escapes the first, so that expectation is corrected to match. Checked against git 2.50.1 (Apple Git-155). Co-Authored-By: Codex <[email protected]>
JingHao-Leon
force-pushed
the
fix/config-unquoted-escape-parsing
branch
from
October 19, 2026 11:16
fd7027c to
983e182
Compare
JingHao-Leon
marked this pull request as ready for review
October 19, 2026 12:02
- [P2] Ignore comment text when validating continued values — /Users/byron/dev/github.com/gitpython-developers/GitPython.fix-config-unquoted -escape-parsing/git/config.py:576-577 With `k = one\` followed by ` two # C:\Users`, the joined value still contains the second line's comment. This check treats its `\U` as an unknown escape and skips `parse_value()`, returning `one two # C:\Users` instead of `one two`, unlike Git and `main`. Updating an unrelated option then persists the comment as part of the value. Strip or skip unquoted comment text before validating escapes. - [P2] Preserve whitespace before an EOF continuation backslash — /Users/byron/dev/github.com/gitpython-developers/GitPython.fix-config-unquoted -escape-parsing/git/config.py:652-653 If the final config line is `k = value \`, with or without a terminating newline, Git and `main` return `"value "`. The EOF branch removes the backslash first, so this newly applied `parse_value()` discards the preceding space and returns `"value"`. Updating an unrelated option also persists that change. Preserve whitespace made significant by the continuation when decoding. Assisted-by: GPT 6.1 Sol Co-authored-by: GPT 6.1 Sol <[email protected]>
It's just noise and I don't even read such issues (nor do I read the PRs in full).
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