44
44
return self._get_best_value('_get_user_id')
47
class GitConfigSectionDefault(config.Section):
48
"""The "default" config section in git config file"""
50
def __init__(self, config):
53
def get(self, name, default=None, expand=True):
56
email = self._config.get((b'user', ), b'email')
60
name = self._config.get((b'user', ), b'name')
63
return '%s <%s>' % (name.decode(), email.decode())
64
if name == 'gpg_signing_key':
66
key = self._config.get((b'user', ), b'signingkey')
73
class GitConfigStore(config.Store):
74
"""Store that uses gitconfig."""
76
def __init__(self, config):
79
def get_sections(self):
81
(self, GitConfigSectionDefault(self._config)),
47
85
class GitBranchStack(config._CompatibleStack):
48
86
"""GitBranch stack."""
50
88
def __init__(self, branch):
89
section_getters = [self._get_overrides]
51
90
lstore = config.LocationStore()
52
91
loc_matcher = config.LocationMatcher(lstore, branch.base)
92
section_getters.append(loc_matcher.get_sections)
53
93
# FIXME: This should also be looking in .git/config for
54
94
# local git branches.
95
git = getattr(branch.repository, '_git', None)
97
cstore = GitConfigStore(git.get_config())
98
section_getters.append(cstore.get_sections)
55
99
gstore = config.GlobalStore()
100
section_getters.append(gstore.get_sections)
56
101
super(GitBranchStack, self).__init__(
58
loc_matcher.get_sections,
60
103
# All modifications go to the corresponding section in
62
105
lstore, branch.base)