From 4ebe407493363a814f590a97f3734364e6c5c1e1 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sat, 7 Jun 2025 22:33:35 -0400 Subject: [PATCH 1/2] Test that ConfigParser treats empty quotes as an empty value The ConfigParser has supported this for a long time, but it is now done redundantly since #2035. This adds a test for it, both to make clearer that it is intended to work and to allow verifying that it continues to hold once the legacy special-casing for it is removed. --- test/fixtures/git_config_with_empty_quotes | 2 ++ test/test_config.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 test/fixtures/git_config_with_empty_quotes diff --git a/test/fixtures/git_config_with_empty_quotes b/test/fixtures/git_config_with_empty_quotes new file mode 100644 index 000000000..f11fe4248 --- /dev/null +++ b/test/fixtures/git_config_with_empty_quotes @@ -0,0 +1,2 @@ +[core] + filemode = "" diff --git a/test/test_config.py b/test/test_config.py index 879b98365..76b918a54 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -416,6 +416,10 @@ def test_config_with_quotes(self): self.assertEqual(cr.get("user", "name"), "Cody Veal") self.assertEqual(cr.get("user", "email"), "cveal05@gmail.com") + def test_config_with_empty_quotes(self): + cr = GitConfigParser(fixture_path("git_config_with_empty_quotes"), read_only=True) + self.assertEqual(cr.get("core", "filemode"), "", "quotes can form a literal empty string as value") + def test_config_with_quotes_with_literal_whitespace(self): cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace_inside"), read_only=True) self.assertEqual(cr.get("core", "commentString"), "# ") From 2f225244286567b72c865fc7c0219c7dc043575f Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sat, 7 Jun 2025 22:59:24 -0400 Subject: [PATCH 2/2] Remove explicit empty `""` handling in ConfigParser Because literal `""` is a special case of `"..."` as parsed since #2035. --- git/config.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/git/config.py b/git/config.py index 1d58db53a..cdcc32e7b 100644 --- a/git/config.py +++ b/git/config.py @@ -501,9 +501,6 @@ def string_decode(v: str) -> str: if pos != -1 and optval[pos - 1].isspace(): optval = optval[:pos] optval = optval.strip() - if optval == '""': - optval = "" - # END handle empty string optname = self.optionxform(optname.rstrip()) if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"': is_multi_line = True