Skip to content

Commit

Permalink
Asterisk can match an empty string too.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Jul 16, 2017
1 parent 9e36784 commit e553e00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dulwich/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def translate(pat):
c = pat[i:i+1]
i = i+1
if c == b'*':
res = res + b'[^/]+'
res = res + b'[^/]*'
elif c == b'?':
res = res + b'.'
elif c == b'[':
Expand Down
5 changes: 3 additions & 2 deletions dulwich/tests/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

POSITIVE_MATCH_TESTS = [
(b"foo.c", b"*.c"),
(b".c", b"*.c"),
(b"foo/foo.c", b"*.c"),
(b"foo/foo.c", b"foo.c"),
(b"foo.c", b"/*.c"),
Expand All @@ -66,9 +67,9 @@


TRANSLATE_TESTS = [
(b"*.c", b'(?ms)(.*/)?[^/]+\\.c/?\\Z'),
(b"*.c", b'(?ms)(.*/)?[^/]*\\.c/?\\Z'),
(b"foo.c", b'(?ms)(.*/)?foo\\.c/?\\Z'),
(b"/*.c", b'(?ms)[^/]+\\.c/?\\Z'),
(b"/*.c", b'(?ms)[^/]*\\.c/?\\Z'),
(b"/foo.c", b'(?ms)foo\\.c/?\\Z'),
(b"foo.c", b'(?ms)(.*/)?foo\\.c/?\\Z'),
(b"foo.[ch]", b'(?ms)(.*/)?foo\\.[ch]/?\\Z'),
Expand Down

0 comments on commit e553e00

Please sign in to comment.