Skip to content

Commit 38b44c3

Browse files
committed
tests: status: additional test for negative ignores with pattern
This test is by Carlos Martín Nieto.
1 parent b8922fc commit 38b44c3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/status/ignore.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,3 +1155,30 @@ void test_status_ignore__subdir_ignore_everything_except_certain_files(void)
11551155
refute_is_ignored("project/src/foo.c");
11561156
refute_is_ignored("project/src/foo/foo.c");
11571157
}
1158+
1159+
void test_status_ignore__deeper(void)
1160+
{
1161+
int ignored;
1162+
1163+
g_repo = cl_git_sandbox_init("empty_standard_repo");
1164+
1165+
cl_git_mkfile("empty_standard_repo/.gitignore",
1166+
"*.data\n"
1167+
"!dont_ignore/*.data\n");
1168+
1169+
cl_git_pass(p_mkdir("empty_standard_repo/dont_ignore", 0777));
1170+
cl_git_mkfile("empty_standard_repo/foo.data", "");
1171+
cl_git_mkfile("empty_standard_repo/bar.data", "");
1172+
cl_git_mkfile("empty_standard_repo/dont_ignore/foo.data", "");
1173+
cl_git_mkfile("empty_standard_repo/dont_ignore/bar.data", "");
1174+
1175+
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "foo.data"));
1176+
cl_assert_equal_i(1, ignored);
1177+
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "bar.data"));
1178+
cl_assert_equal_i(1, ignored);
1179+
1180+
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "dont_ignore/foo.data"));
1181+
cl_assert_equal_i(0, ignored);
1182+
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "dont_ignore/bar.data"));
1183+
cl_assert_equal_i(0, ignored);
1184+
}

0 commit comments

Comments
 (0)