summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--git_config.py6
-rw-r--r--tests/test_git_config.py9
2 files changed, 13 insertions, 2 deletions
diff --git a/git_config.py b/git_config.py
index e658b059..e1e20463 100644
--- a/git_config.py
+++ b/git_config.py
@@ -265,9 +265,11 @@ class GitConfig(object):
265 This internal method populates the GitConfig cache. 265 This internal method populates the GitConfig cache.
266 266
267 """ 267 """
268 d = self._do('--null', '--list').rstrip('\0')
269 c = {} 268 c = {}
270 for line in d.split('\0'): 269 d = self._do('--null', '--list')
270 if d is None:
271 return c
272 for line in d.rstrip('\0').split('\0'):
271 if '\n' in line: 273 if '\n' in line:
272 key, val = line.split('\n', 1) 274 key, val = line.split('\n', 1)
273 else: 275 else:
diff --git a/tests/test_git_config.py b/tests/test_git_config.py
index d67a8bab..5b1770e7 100644
--- a/tests/test_git_config.py
+++ b/tests/test_git_config.py
@@ -39,5 +39,14 @@ class GitConfigUnitTest(unittest.TestCase):
39 val = self.config.GetString('section.nonempty') 39 val = self.config.GetString('section.nonempty')
40 self.assertEqual(val, 'true') 40 self.assertEqual(val, 'true')
41 41
42 def test_GetString_from_missing_file(self):
43 """
44 Test missing config file
45 """
46 config_fixture = fixture('not.present.gitconfig')
47 config = git_config.GitConfig(config_fixture)
48 val = config.GetString('empty')
49 self.assertEqual(val, None)
50
42if __name__ == '__main__': 51if __name__ == '__main__':
43 unittest.main() 52 unittest.main()