From 6239093079dc351b5f7269b662153eeed6c659bf Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Sun, 28 Aug 2022 21:42:41 +0300 Subject: [PATCH] Faster. --- pathspec/patterns/gitwildmatch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pathspec/patterns/gitwildmatch.py b/pathspec/patterns/gitwildmatch.py index 67e4f01..6df2037 100644 --- a/pathspec/patterns/gitwildmatch.py +++ b/pathspec/patterns/gitwildmatch.py @@ -160,7 +160,7 @@ def pattern_to_regex( if override_regex is None: # Build regular expression from pattern. - output = ['^'] + output = [] need_slash = False end = len(pattern_segs) - 1 for i, seg in enumerate(pattern_segs): @@ -172,7 +172,7 @@ def pattern_to_regex( elif i == 0: # A normalized pattern beginning with double-asterisks # ('**') will match any leading path segments. - output.append('(?:.+/)?') + output.append('(?:^|.+/)') need_slash = False elif i == end: # A normalized pattern ending with double-asterisks ('**')