class GitConfig:
__defaults={
- 'stgit.autoresolved': 'no',
'stgit.smtpserver': 'localhost:25',
'stgit.smtpdelay': '5',
'stgit.pullcmd': 'git pull',
'stgit.autoimerge': 'no',
'stgit.keepoptimized': 'no',
'stgit.extensions': '.ancestor .current .patched',
- 'stgit.shortnr': '5'
+ 'stgit.shortnr': '5',
+ 'stgit.pager': 'less'
}
__cache = None
self.load()
if name not in self.__cache:
self.__cache[name] = [self.__defaults.get(name, None)]
- return self.__cache[name][0]
+ return self.__cache[name][-1]
def getall(self, name):
self.load()
self.__cache[name] = value
def unset(self, name):
- Run('git', 'config', '--unset', name)
- self.__cache[name] = None
+ Run('git', 'config', '--unset', name).run()
+ self.__cache[name] = [None]
def sections_matching(self, regexp):
"""Takes a regexp with a single group, matches it against all
if m:
result.append(m.group(1))
return result
+
+ def get_colorbool(self, name, stdout_is_tty):
+ """Invoke 'git config --get-colorbool' and return the result."""
+ return Run('git', 'config', '--get-colorbool', name,
+ stdout_is_tty).output_one_line()
config=GitConfig()
def config_setup():
global config
- # Set the PAGER environment to the config value (if any)
- pager = config.get('stgit.pager')
- if pager:
- os.environ['PAGER'] = pager
+ os.environ.setdefault('PAGER', config.get('stgit.pager'))
+ os.environ.setdefault('LESS', '-FRSX')
# FIXME: handle EDITOR the same way ?
class ConfigOption: