diff --git a/git/config.py b/git/config.py index 2df99a753..1d58db53a 100644 --- a/git/config.py +++ b/git/config.py @@ -509,7 +509,7 @@ def string_decode(v: str) -> str: is_multi_line = True optval = string_decode(optval[1:]) elif len(optval) > 1 and optval[0] == '"' and optval[-1] == '"': - optval = optval[1:-1].strip() + optval = optval[1:-1] # END handle multi-line # Preserves multiple values for duplicate optnames. cursect.add(optname, optval) diff --git a/test/fixtures/git_config_with_quotes_whitespace b/test/fixtures/git_config_with_quotes_whitespace new file mode 100644 index 000000000..c6014cc61 --- /dev/null +++ b/test/fixtures/git_config_with_quotes_whitespace @@ -0,0 +1,2 @@ +[core] + commentString = "# " diff --git a/test/test_config.py b/test/test_config.py index 886d5b136..671f34046 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -412,6 +412,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_quotes_with_literal_whitespace(self): + cr = GitConfigParser(fixture_path("git_config_with_quotes_whitespace"), read_only=True) + self.assertEqual(cr.get("core", "commentString"), "# ") + def test_get_values_works_without_requiring_any_other_calls_first(self): file_obj = self._to_memcache(fixture_path("git_config_multiple")) cr = GitConfigParser(file_obj, read_only=True)
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: