Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf37011d

Browse files
committed
Fix logic to properly compare glob pattern to value
1 parent8e263b8 commitf37011d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

‎git/config.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
importlogging
1414
importos
1515
importre
16-
importglob
1716
importfnmatch
1817
fromcollectionsimportOrderedDict
1918

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

454453
def_has_includes(self):
455-
returnself._merge_includesandany(
456-
section=='include'orsection.startswith('includeIf ')
457-
forsectioninself.sections()
458-
)
454+
returnself._merge_includesandlen(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-
ifkeywordin ["gitdir","gitdir/i"]:
470+
ifkeyword=="gitdir":
475471
value=osp.expanduser(value)
476-
flags= [re.IGNORECASE]ifkeyword=="gitdir/i"else []
477-
regexp=re.compile(fnmatch.translate(value),*flags)
478-
479-
ifany(
480-
regexp.match(path)isnotNone
481-
andself._repo.git_dir.startswith(path)
482-
forpathinglob.glob(value)
483-
):
472+
iffnmatch.fnmatchcase(self._repo.git_dir,value):
484473
paths+=self.items(section)
485474

475+
elifkeyword=="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+
lambdam:f"[{m.group().lower()}{m.group().upper()}]",
482+
value
483+
)
484+
485+
iffnmatch.fnmatchcase(self._repo.git_dir,value):
486+
paths+=self.items(section)
486487

487488
elifkeyword=="onbranch":
488-
ifvalue==self._repo.active_branch.name:
489+
iffnmatch.fnmatchcase(self._repo.active_branch.name,value):
489490
paths+=self.items(section)
490491

491492
returnpaths

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp