ignore: add failing test for a file mentioning the parent When we mention "src" in src/.gitignore, we wrongly consider src/ itself to be ignored.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/tests/status/ignore.c b/tests/status/ignore.c
index 7cf8803..6b31e77 100644
--- a/tests/status/ignore.c
+++ b/tests/status/ignore.c
@@ -915,3 +915,35 @@ void test_status_ignore__filename_with_cr(void)
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Icon"));
cl_assert_equal_i(1, ignored);
}
+
+void test_status_ignore__subdir_doesnt_match_above(void)
+{
+ int ignored, icase = 0, error;
+ git_config *cfg;
+
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
+
+ cl_git_pass(git_repository_config_snapshot(&cfg, g_repo));
+ error = git_config_get_bool(&icase, cfg, "core.ignorecase");
+ if (error == GIT_ENOTFOUND)
+ error = 0;
+
+ cl_git_pass(error);
+
+ cl_git_pass(p_mkdir("empty_standard_repo/src", 0777));
+ cl_git_pass(p_mkdir("empty_standard_repo/src/src", 0777));
+ cl_git_mkfile("empty_standard_repo/src/.gitignore", "src\n");
+ cl_git_mkfile("empty_standard_repo/.gitignore", "");
+
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "src/test.txt"));
+ cl_assert_equal_i(0, ignored);
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "src/src/test.txt"));
+ cl_assert_equal_i(1, ignored);
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "src/foo/test.txt"));
+ cl_assert_equal_i(0, ignored);
+
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "SRC/src/test.txt"));
+ cl_assert_equal_i(icase, ignored);
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "src/SRC/test.txt"));
+ cl_assert_equal_i(icase, ignored);
+}