Title: A config key written without a value is dropped, where git reads it as true · Issue #2237 · gitpython-developers/GitPython · GitHub
Open Graph Title: A config key written without a value is dropped, where git reads it as true · Issue #2237 · gitpython-developers/GitPython
X Title: A config key written without a value is dropped, where git reads it as true · Issue #2237 · gitpython-developers/GitPython
Description: GitConfigParser cannot read a key that appears with no =, which is valid git config and means true. [flag] enabled git config -f cfg --get flag.enabled -> exit 0, empty output git config -f cfg --type=bool --get flag.enabled -> true git ...
Open Graph Description: GitConfigParser cannot read a key that appears with no =, which is valid git config and means true. [flag] enabled git config -f cfg --get flag.enabled -> exit 0, empty output git config -f cfg --t...
X Description: GitConfigParser cannot read a key that appears with no =, which is valid git config and means true. [flag] enabled git config -f cfg --get flag.enabled -> exit 0, empty output git config -f cfg ...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A config key written without a value is dropped, where git reads it as true","articleBody":"`GitConfigParser` cannot read a key that appears with no `=`, which is valid git config and means true.\n\n```ini\n[flag]\n\tenabled\n```\n\n```\ngit config -f cfg --get flag.enabled -> exit 0, empty output\ngit config -f cfg --type=bool --get flag.enabled -> true\ngit config -f cfg --list -> flag.enabled\n```\n\n```python\n>>> GitConfigParser(\"cfg\", read_only=True).get_value(\"flag\", \"enabled\")\nNoOptionError\n```\n\nThe key is not stored at all. `OPTCRE` requires `[:=]`, so the line does not match, and the branch at `git/config.py:589-594` swallows it:\n\n```python\nelse:\n # Check if it's an option with no value - it's just ignored by git.\n if not self.OPTVALUEONLY.match(line):\n```\n\nThe comment is the part I would fix first regardless of the rest: git does not ignore it. `--list` shows the key and `--type=bool` reads it as true. `OPTVALUEONLY` exists only to recognise these lines so they can be discarded without raising a `ParsingError`.\n\nOne constraint on any fix, which is why I am asking rather than sending a patch. git distinguishes a valueless key from an empty one, and they differ exactly where it matters:\n\n```\n[f]\n\tnovalue --get '' --type=bool true\n\tempty = --get '' --type=bool false\n```\n\nSo storing `\"\"` for the valueless case would make it read as false, the opposite of git. Representing it needs something that `get_value` can render as `\"\"` while the boolean path reads as true.\n\nThere is also a write-back question: such a key is currently dropped on a read-modify-write, and once it parses it would need to be written back without an `=`.\n\nHappy to send the patch with tests if you tell me which representation you want; the write-back ripple is the reason I have not guessed.\n\nFound with git 2.50.1 and GitPython at a9913c7.\n\nAssisted-by: Claude Opus 5 (Claude Code), per the identification rule in CONTRIBUTING.md.","author":{"url":"https://github.com/rawsun007","@type":"Person","name":"rawsun007"},"datePublished":"2026-09-13T06:47:17Z","url":"https://github.com/gitpython-developers/GitPython/issues/2237"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:381f5816-9fd8-8601-d90b-984eced0ef2b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC62:26ECEB:1018008:14A49CC:6B0100BA |
| html-safe-nonce | 971dce59ffd71ff392bca57d8e02a06050b8e28fe8434244e7178af75fb4b014 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzYyOjI2RUNFQjoxMDE4MDA4OjE0QTQ5Q0M6NkIwMTAwQkEiLCJ2aXNpdG9yX2lkIjoiNTYyMzczNDkzMzk4Mjg3MTczOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0d3030f5cd2786bf133beee004d955a3b0e6feb050d805127db18a415148e498 |
| hovercard-subject-tag | issue:5438582911 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/2237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db0e4930efad78d767e0b5ea3a7c2e3c1d4f7a7f21addf36eb540cb52b7a4214/gitpython-developers/GitPython/issues/2237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db0e4930efad78d767e0b5ea3a7c2e3c1d4f7a7f21addf36eb540cb52b7a4214/gitpython-developers/GitPython/issues/2237 |
| og:image:alt | GitConfigParser cannot read a key that appears with no =, which is valid git config and means true. [flag] enabled git config -f cfg --get flag.enabled -> exit 0, empty output git config -f cfg --t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rawsun007 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width