Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d233b4c

Browse filesBrowse files
committed
Fix GitConfigParser not removing quotes from values
1 parent c8ebc8b commit d233b4c
Copy full SHA for d233b4c

3 files changed

+12-1Lines changed: 12 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/config.py‎

Copy file name to clipboardExpand all lines: git/config.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ def string_decode(v: str) -> str:
508508
if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"':
509509
is_multi_line = True
510510
optval = string_decode(optval[1:])
511+
elif len(optval) > 1 and optval[0] == '"' and optval[-1] == '"':
512+
optval = optval[1:-1]
511513
# END handle multi-line
512514
# Preserves multiple values for duplicate optnames.
513515
cursect.add(optname, optval)
Collapse file
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[user]
2+
name = "Cody Veal"
3+
email = "cveal05@gmail.com"
Collapse file

‎test/test_config.py‎

Copy file name to clipboardExpand all lines: test/test_config.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def test_complex_aliases(self):
391391
with GitConfigParser(file_obj, read_only=False) as w_config:
392392
self.assertEqual(
393393
w_config.get("alias", "rbi"),
394-
'"!g() { git rebase -i origin/${1:-master} ; } ; g"',
394+
"!g() { git rebase -i origin/${1:-master} ; } ; g",
395395
)
396396
self.assertEqual(
397397
file_obj.getvalue(),
@@ -406,6 +406,12 @@ def test_empty_config_value(self):
406406
with self.assertRaises(cp.NoOptionError):
407407
cr.get_value("color", "ui")
408408

409+
def test_config_with_quotes(self):
410+
cr = GitConfigParser(fixture_path("git_config_with_quotes"), read_only=True)
411+
412+
self.assertEqual(cr.get("user", "name"), "Cody Veal")
413+
self.assertEqual(cr.get("user", "email"), "cveal05@gmail.com")
414+
409415
def test_get_values_works_without_requiring_any_other_calls_first(self):
410416
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
411417
cr = GitConfigParser(file_obj, read_only=True)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.