Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pathspec/patterns/gitignore/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ def __translate_segments(
# Match whole path segment.
out_parts.append('[^/]+')

elif seg == '**\\':
elif seg == '**\\' and i < end:
# EDGE CASE: Git does not match a root path with `**\` like it does
# `**`.
# `**`. A final `**\` is a trailing backslash, which is handled
# below as an invalid pattern.
out_parts.append('(?s:.+)')

else:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_04_gitignore_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
]] = [
('\\', [None, 'literal', 'null'], ['raise']),
('a\\', [None, 'literal', 'null'], ['raise']),
('**\\', [None, 'literal', 'null'], ['raise']),
('a/**\\', [None, 'literal', 'null'], ['raise']),
]
"""
Escaped slash failure test cases.
Expand Down