diff --git a/git/config.py b/git/config.py index 71d7ea689..e05a297af 100644 --- a/git/config.py +++ b/git/config.py @@ -796,6 +796,7 @@ def get_values( :raise TypeError: in case the value could not be understood Otherwise the exceptions known to the ConfigParser will be raised.""" try: + self.sections() lst = self._sections[section].getall(option) except Exception: if default is not None: diff --git a/test/test_config.py b/test/test_config.py index 8bb2aa306..b159ebe2d 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -398,6 +398,17 @@ def test_empty_config_value(self): with self.assertRaises(cp.NoOptionError): cr.get_value("color", "ui") + 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) + self.assertEqual(cr.get_values("section0", "option0"), ["value0"]) + file_obj.seek(0) + cr = GitConfigParser(file_obj, read_only=True) + self.assertEqual(cr.get_values("section1", "option1"), ["value1a", "value1b"]) + file_obj.seek(0) + cr = GitConfigParser(file_obj, read_only=True) + self.assertEqual(cr.get_values("section1", "other_option1"), ["other_value1"]) + def test_multiple_values(self): file_obj = self._to_memcache(fixture_path("git_config_multiple")) with GitConfigParser(file_obj, read_only=False) as cw: