diff options
author | Patrick Steinhardt <ps@pks.im> | 2015-03-24 18:33:50 +0300 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2015-04-17 10:59:16 +0300 |
commit | 4f3586034b3db317d360de87bd962de1ef3d524e (patch) | |
tree | 7a531778b1c5758b4fd01f21ea7a380377bc42c2 /tests/status | |
parent | 2a0f67f04cb717a7e57192696d69f91a3d208705 (diff) |
ignore: fix negative ignores without wildcards.
Diffstat (limited to 'tests/status')
-rw-r--r-- | tests/status/ignore.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/status/ignore.c b/tests/status/ignore.c index a15b11d1d..3193d318e 100644 --- a/tests/status/ignore.c +++ b/tests/status/ignore.c @@ -892,6 +892,59 @@ void test_status_ignore__negative_ignores_without_trailing_slash_inside_ignores( cl_assert(found_parent_child2_file); } +void test_status_ignore__negative_directory_ignores(void) +{ + static const char *test_files[] = { + "empty_standard_repo/parent/child1/bar.txt", + "empty_standard_repo/parent/child2/bar.txt", + "empty_standard_repo/parent/child3/foo.txt", + "empty_standard_repo/parent/child4/bar.txt", + "empty_standard_repo/parent/nested/child5/bar.txt", + "empty_standard_repo/parent/nested/child6/bar.txt", + "empty_standard_repo/parent/nested/child7/bar.txt", + "empty_standard_repo/padded_parent/child8/bar.txt", + NULL + }; + + make_test_data("empty_standard_repo", test_files); + cl_git_mkfile( + "empty_standard_repo/.gitignore", + "foo.txt\n" + "parent/child1\n" + "parent/child2\n" + "parent/child4\n" + "parent/nested/child5\n" + "nested/child6\n" + "nested/child7\n" + "padded_parent/child8\n" + /* test simple exact match */ + "!parent/child1\n" + /* test negating file without negating dir */ + "!parent/child2/bar.txt\n" + /* test negative pattern on dir with its content + * being ignored */ + "!parent/child3\n" + /* test with partial match at end */ + "!child4\n" + /* test with partial match with '/' at end */ + "!nested/child5\n" + /* test with complete match */ + "!nested/child6\n" + /* test with trailing '/' */ + "!child7/\n" + /* test with partial dir match */ + "!_parent/child8\n"); + + refute_is_ignored("parent/child1/bar.txt"); + assert_is_ignored("parent/child2/bar.txt"); + assert_is_ignored("parent/child3/foo.txt"); + refute_is_ignored("parent/child4/bar.txt"); + assert_is_ignored("parent/nested/child5/bar.txt"); + refute_is_ignored("parent/nested/child6/bar.txt"); + refute_is_ignored("parent/nested/child7/bar.txt"); + assert_is_ignored("padded_parent/child8/bar.txt"); +} + void test_status_ignore__filename_with_cr(void) { int ignored; |