summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorJeremy Retailleau <jeremy.retailleau@gmail.com>2020-09-02 17:38:43 -0700
committerJeremy Retailleau <jeremy.retailleau@gmail.com>2020-09-02 17:38:43 -0700
commitc3fc83f2333eaee5fbcbef6df9f4ed9eb320fd11 (patch)
tree623b4a3b380ad9c83fbc58a19c1ce23b36747c97 /git
parent16d3ebfa3ad32d281ebdd77de587251015d04b3b (diff)
downloadgitpython-c3fc83f2333eaee5fbcbef6df9f4ed9eb320fd11.tar.gz
Add missing rules to match hierarchy path
Diffstat (limited to 'git')
-rw-r--r--git/config.py28
1 files changed, 16 insertions, 12 deletions
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)