Skip to content

Preserve implicit boolean config keys - #2238

Merged
Byron merged 1 commit into
mainfrom
read-implicit-bool
Sep 13, 2026
Merged

Preserve implicit boolean config keys#2238
Byron merged 1 commit into
mainfrom
read-implicit-bool

Conversation

@Byron

@Byron Byron commented Sep 13, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #2237.

Bare config keys were dropped during parsing and disappeared when an unrelated setting was written. Preserve them as None, following RawConfigParser's valueless-option representation. get_value() and get_values() expose an empty string, while getboolean() returns True; explicitly empty assignments return False through getboolean(). Write-back retains bare syntax and repeated occurrences.

The regression covers bare keys, trailing whitespace, a final line without a newline, quoted and unquoted empty values, repeated values, and a valueless non-path option in an include section. It compares Git's NUL-delimited listing before and after an unrelated edit and verifies the resulting boolean values.

Validation on Python 3.12.14: 41 configuration tests passed, 2 existing skips; Ruff lint and formatting, mypy (46 source files), basedpyright, and git diff --check passed. Both regressions failed before the fix.

Codex review of 0b6c1682 found no actionable regressions.

Git reference: 1630431f326e15fcde608827b5ff38422528eb59, t/t1300-config.sh tests for valueless versus empty values, and parse.c:git_parse_maybe_bool_text. Runtime comparisons used Git 2.50.1 (Apple Git-155).

This was mostly a rubber-stamp, knowing the the whole implementation is quite
a hack that is held together with ductape. Ideally, it will just work well enough
at some point, to gain time for v4 to be made.

<!-- agent -->
GitConfigParser discarded keys written without an assignment. Reading such
an option raised NoOptionError, and editing an unrelated setting silently
removed it. Git treats a bare key as true but an explicitly empty value as
false, so representing both as an empty string would lose their meaning.

Store bare entries as None, following RawConfigParser's allow_no_value
representation. Raw get/items access preserves the distinction, while
get_value/get_values return an empty string as requested. Convert None to
true and an empty string to false in getboolean, retaining the standard
boolean spellings. Write None entries without an equals sign and exclude
them from string validation and include-path expansion. The existing
ordered multi-dict preserves repeated bare and assigned entries together.

Update the regression that expected bare color.ui to disappear, and add a
Git-backed read-modify-write test covering trailing whitespace, EOF without
a newline, quoted and unquoted empty values, repeated keys, and a valueless
non-path option in an include section. Both regressions failed before the
fix. Compare Git's NUL-delimited listing before and after an unrelated edit
and check the resulting repeated values with --type=bool --get-all.

Git reference: checkout 1630431f326e15fcde608827b5ff38422528eb59,
t/t1300-config.sh tests for novalue.variable and emptyvalue.variable, and
parse.c:git_parse_maybe_bool_text. Runtime comparison used Git 2.50.1
(Apple Git-155).

Assisted-by: GPT 6.0
Co-authored-by: GPT 6.0 <codex@openai.com>
@Byron
Byron force-pushed the read-implicit-bool branch from 0b6c168 to 2229668 Compare September 13, 2026 15:16
@Byron
Byron marked this pull request as ready for review September 13, 2026 15:42
Copilot AI lite review requested due to automatic review settings September 13, 2026 15:42
@Byron
Byron merged commit d171e34 into main Sep 13, 2026
54 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Valueless keys followed by inline comments are parsed incorrectly and need to be fixed.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Preserves Git-style valueless configuration keys through parsing, access, and write-back.

Changes:

  • Stores valueless options as None.
  • Preserves repeated entries and bare syntax during serialization.
  • Adds regression coverage for boolean semantics and round-tripping.
File summaries
File Summary
test/test_config.py Adds coverage for implicit booleans, empty values, duplicates, includes, and round-tripping.
git/config.py Implements valueless-option handling and serialization; inline comments on bare keys still require correction.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread git/config.py
@Byron
Byron deleted the read-implicit-bool branch September 13, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

A config key written without a value is dropped, where git reads it as true

2 participants