Repository navigation
Commit fd7027c
fix(config): decode escapes in unquoted config values
Git decodes backslash escapes in unquoted configuration values exactly as
it does in quoted ones, 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 changed meaning 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.
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 <codex@openai.com>1 parent 9d3aff0 commit fd7027c
3 files changed
Lines changed: 32 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
610 | 609 | | |
611 | 610 | | |
612 | 611 | | |
| |||
620 | 619 | | |
621 | 620 | | |
622 | 621 | | |
623 | | - | |
624 | | - | |
625 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
| 368 | + | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| |||
1209 | 1209 | | |
1210 | 1210 | | |
1211 | 1211 | | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
1212 | 1229 | | |
1213 | 1230 | | |
1214 | 1231 | | |
| |||
0 commit comments