aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@gmail.com>2010-02-05 13:45:01 +0000
committerCatalin Marinas <catalin.marinas@gmail.com>2010-02-05 13:45:01 +0000
commitd0329a7785d86495fd02ca595d9cb94fc67cdf4d (patch)
tree97a5586b2d80668c2a37ece70b7f9c9827b0f80f
parent35112e505fff1c37f9261313060c730c47ab47c8 (diff)
downloadstgit-d0329a7785d86495fd02ca595d9cb94fc67cdf4d.tar.gz
Populate the cached config options with the defaults
The patch pre-populates the cached config options with the default values. It also removes an unused option (stgit.extensions). Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r--stgit/config.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/stgit/config.py b/stgit/config.py
index 796f2c9..811138d 100644
--- a/stgit/config.py
+++ b/stgit/config.py
@@ -28,16 +28,15 @@ class GitConfigException(StgException):
class GitConfig:
__defaults={
- 'stgit.smtpserver': 'localhost:25',
- 'stgit.smtpdelay': '5',
- 'stgit.pullcmd': 'git pull',
- 'stgit.fetchcmd': 'git fetch',
- 'stgit.pull-policy': 'pull',
- 'stgit.autoimerge': 'no',
- 'stgit.keepoptimized': 'no',
- 'stgit.extensions': '.ancestor .current .patched',
- 'stgit.shortnr': '5',
- 'stgit.pager': 'less'
+ 'stgit.smtpserver': ['localhost:25'],
+ 'stgit.smtpdelay': ['5'],
+ 'stgit.pullcmd': ['git pull'],
+ 'stgit.fetchcmd': ['git fetch'],
+ 'stgit.pull-policy': ['pull'],
+ 'stgit.autoimerge': ['no'],
+ 'stgit.keepoptimized': ['no'],
+ 'stgit.shortnr': ['5'],
+ 'stgit.pager': ['less']
}
__cache = None
@@ -47,7 +46,7 @@ class GitConfig:
done already."""
if self.__cache is not None:
return
- self.__cache = {}
+ self.__cache = self.__defaults
lines = Run('git', 'config', '--null', '--list'
).discard_exitcode().raw_output()
for line in filter(None, lines.split('\0')):
@@ -56,9 +55,10 @@ class GitConfig:
def get(self, name):
self.load()
- if name not in self.__cache:
- self.__cache[name] = [self.__defaults.get(name, None)]
- return self.__cache[name][-1]
+ try:
+ return self.__cache[name][-1]
+ except KeyError:
+ return None
def getall(self, name):
self.load()