summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-08-19 15:07:22 +0000
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-08-19 15:07:22 +0000
commit7e2553e2101310e9ddfce2ca93c1c923b062ad1e (patch)
tree369615f5aca17bd0e83b46853774836a35d372c7
parent7aec8c2eb0f8ce0dae70559d11db8e84115f8ba6 (diff)
downloadmorph-7e2553e2101310e9ddfce2ca93c1c923b062ad1e.tar.gz
Cache configuration values in GitDirectory.
This reduces the vast number of 'git config -z core.bare' which we used to get a lot of, to one or two per run. It doesn't save much time, but it does make logs less full of confusion. Reviewed-By: Richard maw <richard.maw@codethink.co.uk> +2
-rw-r--r--morphlib/gitdir.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py
index fea26c2e..6b04b773 100644
--- a/morphlib/gitdir.py
+++ b/morphlib/gitdir.py
@@ -355,6 +355,7 @@ class GitDirectory(object):
# so we just use the provided dirname
if not self.dirname:
self.dirname = dirname
+ self._config = {}
def _runcmd(self, argv, **kwargs):
'''Run a command at the root of the git directory.
@@ -447,12 +448,15 @@ class GitDirectory(object):
'''
self._runcmd(['git', 'config', key, value])
+ self._config[key] = value
def get_config(self, key):
'''Return value for a git repository configuration variable.'''
- value = self._runcmd(['git', 'config', '-z', key])
- return value.rstrip('\0')
+ if key not in self._config:
+ value = self._runcmd(['git', 'config', '-z', key])
+ self._config[key] = value.rstrip('\0')
+ return self._config[key]
def get_remote(self, *args, **kwargs):
'''Get a remote for this Repository.