Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f37011d

Browse filesBrowse files
committed
Fix logic to properly compare glob pattern to value
1 parent 8e263b8 commit f37011d
Copy full SHA for f37011d

1 file changed

+16-15Lines changed: 16 additions & 15 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/config.py‎

Copy file name to clipboardExpand all lines: git/config.py
+16-15Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import logging
1414
import os
1515
import re
16-
import glob
1716
import fnmatch
1817
from collections import OrderedDict
1918

@@ -452,10 +451,7 @@ def string_decode(v):
452451
raise e
453452

454453
def _has_includes(self):
455-
return self._merge_includes and any(
456-
section == 'include' or section.startswith('includeIf ')
457-
for section in self.sections()
458-
)
454+
return self._merge_includes and len(self._included_paths())
459455

460456
def _included_paths(self):
461457
"""Return all paths that must be included to configuration.
@@ -471,21 +467,26 @@ def _included_paths(self):
471467
keyword = match.group(1)
472468
value = match.group(2).strip()
473469

474-
if keyword in ["gitdir", "gitdir/i"]:
470+
if keyword == "gitdir":
475471
value = osp.expanduser(value)
476-
flags = [re.IGNORECASE] if keyword == "gitdir/i" else []
477-
regexp = re.compile(fnmatch.translate(value), *flags)
478-
479-
if any(
480-
regexp.match(path) is not None
481-
and self._repo.git_dir.startswith(path)
482-
for path in glob.glob(value)
483-
):
472+
if fnmatch.fnmatchcase(self._repo.git_dir, value):
484473
paths += self.items(section)
485474

475+
elif keyword == "gitdir/i":
476+
value = osp.expanduser(value)
477+
478+
# Ensure that glob is always case insensitive.
479+
value = re.sub(
480+
r"[a-zA-Z]",
481+
lambda m: f"[{m.group().lower()}{m.group().upper()}]",
482+
value
483+
)
484+
485+
if fnmatch.fnmatchcase(self._repo.git_dir, value):
486+
paths += self.items(section)
486487

487488
elif keyword == "onbranch":
488-
if value == self._repo.active_branch.name:
489+
if fnmatch.fnmatchcase(self._repo.active_branch.name, value):
489490
paths += self.items(section)
490491

491492
return paths

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.