From c3fc83f2333eaee5fbcbef6df9f4ed9eb320fd11 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Wed, 2 Sep 2020 17:38:43 -0700 Subject: Add missing rules to match hierarchy path --- git/config.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'git') diff --git a/git/config.py b/git/config.py index e36af9fe..eb46c41b 100644 --- a/git/config.py +++ b/git/config.py @@ -467,20 +467,24 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje keyword = match.group(1) value = match.group(2).strip() - if keyword == "gitdir": - value = osp.expanduser(value) - if fnmatch.fnmatchcase(self._repo.git_dir, value): - paths += self.items(section) - - elif keyword == "gitdir/i": + if keyword in ["gitdir", "gitdir/i"]: value = osp.expanduser(value) - # Ensure that glob is always case insensitive. - value = re.sub( - r"[a-zA-Z]", - lambda m: f"[{m.group().lower()}{m.group().upper()}]", - 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) -- cgit v1.2.1