Commit 2d4f068
fix: reject comments after implicit boolean config keys
Note that this is just a fixup, on a huge hack which is the native
git-config parsing. Let's just hope this holds up until v4.
<!-- agent -->
GitConfigParser accepted entries such as "enabled # comment" and
"enabled ; comment" even though Git rejects them. The comment became
part of the option name, and an equals sign or colon inside the comment
could make the entry look like an assignment. Silently stripping the
comment would also accept configuration that Git considers invalid.
Exclude both comment markers from the shared option-name expression and
require a full-line match for valueless options. The assignment pattern
cannot cross a comment marker, and the valueless fallback cannot accept
just the valid-looking prefix. Such lines now raise the existing
ParsingError during reading or an attempted edit. Ordinary bare keys
retain their implicit true value and round-trip behavior.
Add six regression cases covering both markers, spaces, tabs, adjacent
comments, and assignment delimiters inside comments. Compare rejection
with git config, check both getboolean and an unrelated edit raise
ParsingError, and verify that the failed edit leaves the original bytes
untouched. All six cases failed before full-line matching was added.
Git reference: checkout 1630431f326e15fcde608827b5ff38422528eb59,
config.c:get_value. Without an assignment, that parser requires the
line to end after the key and optional whitespace. Runtime comparisons
used Git 2.50.1 (Apple Git-155), which rejected all six inputs with
exit status 128.
Validation on Python 3.12.14: 42 configuration tests and six regression
subtests passed, with two existing skips. Ruff lint and formatting and
git diff --check passed.
Assisted-by: GPT 6.0
Co-authored-by: GPT 6.0 <codex@openai.com>1 parent d171e34 commit 2d4f068
2 files changed
Lines changed: 35 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
| 597 | + | |
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
920 | 953 | | |
921 | 954 | | |
922 | 955 | | |
| |||
0 commit comments