summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2023-02-16 17:27:50 +0100
committerGitHub <noreply@github.com>2023-02-16 17:27:50 +0100
commit0e5358a7c0d153902eb31f31fa8df9600276a520 (patch)
tree40146438d46d57276d5aa6622570d00cec52b1bf
parent202e31cb4196e74cd190c2644a27b9d5479ba6ed (diff)
parentfc843d31ddb817deb8e5e6732ebe67a5ee61db66 (diff)
downloadgitpython-0e5358a7c0d153902eb31f31fa8df9600276a520.tar.gz
Merge pull request #1555 from Codym48/fix/get_values
Fix get_values() so it correctly loads section names
-rw-r--r--git/config.py1
-rw-r--r--test/test_config.py11
2 files changed, 12 insertions, 0 deletions
diff --git a/git/config.py b/git/config.py
index 71d7ea68..e05a297a 100644
--- a/git/config.py
+++ b/git/config.py
@@ -796,6 +796,7 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
: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 8bb2aa30..b159ebe2 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -398,6 +398,17 @@ class TestBase(TestCase):
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: