Skip to content

Commit cf8029d

Browse files
authored
Merge pull request #2036 from EliahKagan/quoted-whitespace
Preserve quoted leading and trailing single-line config var whitespace
2 parents 4dd5d45 + bd2b930 commit cf8029d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

git/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def string_decode(v: str) -> str:
509509
is_multi_line = True
510510
optval = string_decode(optval[1:])
511511
elif len(optval) > 1 and optval[0] == '"' and optval[-1] == '"':
512-
optval = optval[1:-1].strip()
512+
optval = optval[1:-1]
513513
# END handle multi-line
514514
# Preserves multiple values for duplicate optnames.
515515
cursect.add(optname, optval)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[core]
2+
commentString = "# "

test/test_config.py

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

415+
def test_config_with_quotes_with_literal_whitespace(self):
416+
cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace"), read_only=True)
417+
self.assertEqual(cr.get("core", "commentString"), "# ")
418+
415419
def test_get_values_works_without_requiring_any_other_calls_first(self):
416420
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
417421
cr = GitConfigParser(file_obj, read_only=True)

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