Skip to content

Commit 646dc16

Browse files
authored
Merge pull request #2047 from EliahKagan/quoted-empty
Remove explicit empty `""` handling in ConfigParser
2 parents 63160de + 2f22524 commit 646dc16

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

git/config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,6 @@ def string_decode(v: str) -> str:
501501
if pos != -1 and optval[pos - 1].isspace():
502502
optval = optval[:pos]
503503
optval = optval.strip()
504-
if optval == '""':
505-
optval = ""
506-
# END handle empty string
507504
optname = self.optionxform(optname.rstrip())
508505
if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"':
509506
is_multi_line = True
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[core]
2+
filemode = ""

test/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ def test_config_with_quotes(self):
416416
self.assertEqual(cr.get("user", "name"), "Cody Veal")
417417
self.assertEqual(cr.get("user", "email"), "cveal05@gmail.com")
418418

419+
def test_config_with_empty_quotes(self):
420+
cr = GitConfigParser(fixture_path("git_config_with_empty_quotes"), read_only=True)
421+
self.assertEqual(cr.get("core", "filemode"), "", "quotes can form a literal empty string as value")
422+
419423
def test_config_with_quotes_with_literal_whitespace(self):
420424
cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace_inside"), read_only=True)
421425
self.assertEqual(cr.get("core", "commentString"), "# ")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy