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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2 git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ def string_decode(v: str) -> str:
if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"':
is_multi_line = True
optval = string_decode(optval[1:])
elif len(optval) > 1 and optval[0] == '"' and optval[-1] == '"':
optval = optval[1:-1].strip()
Comment thread
EliahKagan marked this conversation as resolved.
# END handle multi-line
# Preserves multiple values for duplicate optnames.
cursect.add(optname, optval)
Expand Down
3 changes: 3 additions & 0 deletions 3 test/fixtures/git_config_with_quotes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[user]
name = "Cody Veal"
email = "cveal05@gmail.com"
8 changes: 7 additions & 1 deletion 8 test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def test_complex_aliases(self):
with GitConfigParser(file_obj, read_only=False) as w_config:
self.assertEqual(
w_config.get("alias", "rbi"),
'"!g() { git rebase -i origin/${1:-master} ; } ; g"',
"!g() { git rebase -i origin/${1:-master} ; } ; g",
)
self.assertEqual(
file_obj.getvalue(),
Expand All @@ -406,6 +406,12 @@ def test_empty_config_value(self):
with self.assertRaises(cp.NoOptionError):
cr.get_value("color", "ui")

def test_config_with_quotes(self):
cr = GitConfigParser(fixture_path("git_config_with_quotes"), read_only=True)

self.assertEqual(cr.get("user", "name"), "Cody Veal")
self.assertEqual(cr.get("user", "email"), "cveal05@gmail.com")

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)
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.