Commit 42566c6
fix: ignore comments after implicit boolean config keys
Bare entries such as "enabled # comment" and "enabled ; comment" retained
the comment in the option name. getboolean("flag", "enabled") therefore
raised NoOptionError, and an unrelated write emitted the malformed key
again. An equals sign or colon inside the comment also made the parser
mistake the entry for an assignment.
Stop the shared option-name expression at either comment marker. Both
the assignment and valueless patterns then extract only the bare name,
preserving its None representation, true boolean value, and bare syntax
on write-back. Quoted values continue through the existing value parser.
Add a round-trip regression covering both comment markers with spaces,
tabs, or no separator, including equals signs and colons in comments.
All six cases failed with NoOptionError before the fix. Check the parsed
name and boolean, exact output after an unrelated edit, and the boolean
read back by both GitPython and git config.
Git reference: checkout 1630431f326e15fcde608827b5ff38422528eb59,
Documentation/config.adoc and config.c:get_value. Despite the general
comment rule in the documentation, that parser and Git 2.50.1 (Apple
Git-155) reject comments after bare keys. Accepting them is the requested
GitPython behavior; the normalized bare-key output is accepted by Git.
Validation on Python 3.12.14: 42 configuration tests and six regression
subtests passed, with two existing skips. Ruff lint and formatting,
mypy (46 source files), basedpyright, and git diff --check passed.1 parent d171e34 commit 42566c6
2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| |||
| 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 | + | |
920 | 950 | | |
921 | 951 | | |
922 | 952 | | |
| |||
0 commit comments