GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reject comments after implicit boolean config keys by Byron · Pull Request #2239 · gitpython-developers/GitPython

Reject comments after implicit boolean config keys #2239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Byron merged 1 commit into main from 2238-follow-up
Sep 13, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Reject comments after implicit boolean config keys #2239

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
2d4f068
fix: reject comments after implicit boolean config keys
Byron Sep 13, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

4 changes: 2 additions & 2 deletions 4 git/config.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
re_comment = re.compile(r"^\s*[#;]")
# } END configuration

optvalueonly_source = r"\s*(?P<option>[^:=\s][^:=]*)"
optvalueonly_source = r"\s*(?P<option>[^:=\s#;][^:=#;]*)"

OPTVALUEONLY = re.compile(optvalueonly_source)

Expand Down Expand Up @@ -594,7 +594,7 @@ def parse_value(value: str) -> str:
cursect.add(optname, optval)
else:
# A valueless option is an implicit boolean true, not an empty value.
mo = self.OPTVALUEONLY.match(line)
mo = self.OPTVALUEONLY.fullmatch(line)
Comment thread
Byron marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

if mo:
optname = self.optionxform(mo.group("option").rstrip())
cursect.add(optname, None)
Expand Down
33 changes: 33 additions & 0 deletions 33 test/test_config.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,39 @@ def test_implicit_boolean_round_trip(self, rw_dir):
self.assertIs(config.getboolean("flag", "empty"), False)
self.assertEqual(dict(config.items_all("flag"))["multiple"], ["false", None, "", None])

@with_rw_directory
def test_implicit_boolean_rejects_comments_like_git(self, rw_dir):
config_path = osp.join(rw_dir, "config")
comments = (
" # comment",
" ; comment",
"# comment = value",
"; comment = value",
"\t# comment: value",
Comment thread
Byron marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

"\t; comment: value",
)
for comment in comments:
with self.subTest(comment=comment):
content = ("[flag]\n\tenabled%s\n" % comment).encode(defenc)
with open(config_path, "wb") as config_file:
config_file.write(content)

result = subprocess.run(
["git", "config", "--file", config_path, "--bool", "flag.enabled"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
self.assertEqual(result.returncode, 128, result.stderr)
with GitConfigParser(config_path) as config:
with self.assertRaises(cp.ParsingError):
config.getboolean("flag", "enabled")
with GitConfigParser(config_path, read_only=False) as config:
with self.assertRaises(cp.ParsingError):
config.set_value("other", "value", "updated")

with open(config_path, "rb") as config_file:
self.assertEqual(config_file.read(), content)

def test_config_with_quotes(self):
cr = GitConfigParser(fixture_path("git_config_with_quotes"), read_only=True)

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.