summaryrefslogtreecommitdiff
path: root/git/index/typ.py
diff options
context:
space:
mode:
authorAustin Scola <austinscola@gmail.com>2022-06-28 08:59:26 -0400
committerAustin Scola <austinscola@gmail.com>2022-06-28 08:59:26 -0400
commited45d5b3c3d4e2d4520221037b40288dc85e428c (patch)
tree922fc17d621fb255636782f6c72fa6251f1ad2c9 /git/index/typ.py
parent420d2afa0ebfa976a07dc0ff902c75547ab228c6 (diff)
downloadgitpython-ed45d5b3c3d4e2d4520221037b40288dc85e428c.tar.gz
Fix blob filter path shorter than filter path
Diffstat (limited to 'git/index/typ.py')
-rw-r--r--git/index/typ.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/git/index/typ.py b/git/index/typ.py
index ec7699e2..b2c6c371 100644
--- a/git/index/typ.py
+++ b/git/index/typ.py
@@ -9,7 +9,7 @@ from git.objects import Blob
# typing ----------------------------------------------------------------------
-from typing import NamedTuple, Sequence, TYPE_CHECKING, Tuple, Union, cast
+from typing import NamedTuple, Sequence, TYPE_CHECKING, Tuple, Union, cast, List
from git.types import PathLike
@@ -57,7 +57,11 @@ class BlobFilter(object):
for pathlike in self.paths:
path: Path = pathlike if isinstance(pathlike, Path) else Path(pathlike)
# TODO: Change to use `PosixPath.is_relative_to` once Python 3.8 is no longer supported.
- if all(i == j for i, j in zip(path.parts, blob_path.parts)):
+ filter_parts: List[str] = path.parts
+ blob_parts: List[str] = blob_path.parts
+ if len(filter_parts) > len(blob_parts):
+ continue
+ if all(i == j for i, j in zip(filter_parts, blob_parts)):
return True
return False