8000 Merge pull request #1555 from Codym48/fix/get_values · Shahzeb42Digital/GitPython@0e5358a · GitHub
[go: up one dir, main page]

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 0e5358a

Browse files
authored
Merge pull request gitpython-developers#1555 from Codym48/fix/get_values
Fix get_values() so it correctly loads section names
2 parents 202e31c + fc843d3 commit 0e5358a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

git/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ def get_values(
796796
:raise TypeError: in case the value could not be understood
797797
Otherwise the exceptions known to the ConfigParser will be raised."""
798798
try:
799+
self.sections()
799800
lst = self._sections[section].getall(option)
800801
except Exception:
801802
if default is not None:

test/test_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,17 @@ def test_empty_config_value(self):
398398
with self.assertRaises(cp.NoOptionError):
399399
cr.get_value("color", "ui")
400400

401+
def test_get_values_works_without_requiring_any_other_calls_first(self):
402+
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
403+
cr = GitConfigParser(file_obj, read_only=True)
404+
self.assertEqual(cr.get_values("section0", "option0"), ["value0"])
405+
file_obj.seek(0)
406+
cr = GitConfigParser(file_obj, read_only=True)
407+
self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b"])
408+
file_obj.seek(0)
409+
cr = GitConfigParser(file_obj, read_only=True)
410+
self.assertEqual(cr.get_values("section1", "other_option1"), ["other_value1"])
411+
401412
def test_multiple_values(self):
402413
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
403414
with GitConfigParser(file_obj, read_only=False) as cw:

0 commit comments

Comments
 (0)
0