diff options
Diffstat (limited to 'git/config.py')
-rw-r--r-- | git/config.py | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/git/config.py b/git/config.py index f9a5a46b..b49f0790 100644 --- a/git/config.py +++ b/git/config.py @@ -464,35 +464,37 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje paths += self.items(section) match = CONDITIONAL_INCLUDE_REGEXP.search(section) - if match is not None and self._repo is not None: - keyword = match.group(1) - value = match.group(2).strip() - - if keyword in ["gitdir", "gitdir/i"]: - value = osp.expanduser(value) - - if not any(value.startswith(s) for s in ["./", "/"]): - value = "**/" + value - if value.endswith("/"): - value += "**" - - # Ensure that glob is always case insensitive if required. - if keyword.endswith("/i"): - value = re.sub( - r"[a-zA-Z]", - lambda m: "[{}{}]".format( - m.group().lower(), - m.group().upper() - ), - value - ) - - if fnmatch.fnmatchcase(self._repo.git_dir, value): - paths += self.items(section) - - elif keyword == "onbranch": - if fnmatch.fnmatchcase(self._repo.active_branch.name, value): - paths += self.items(section) + if match is None or self._repo is None: + continue + + keyword = match.group(1) + value = match.group(2).strip() + + if keyword in ["gitdir", "gitdir/i"]: + value = osp.expanduser(value) + + if not any(value.startswith(s) for s in ["./", "/"]): + value = "**/" + value + if value.endswith("/"): + value += "**" + + # Ensure that glob is always case insensitive if required. + if keyword.endswith("/i"): + value = re.sub( + r"[a-zA-Z]", + lambda m: "[{}{}]".format( + m.group().lower(), + m.group().upper() + ), + value + ) + + if fnmatch.fnmatchcase(self._repo.git_dir, value): + paths += self.items(section) + + elif keyword == "onbranch": + if fnmatch.fnmatchcase(self._repo.active_branch.name, value): + paths += self.items(section) return paths |