Commit 0798b01400315db85715277d00f7a1262a5ed125

Carlos Martín Nieto 2014-10-04T11:48:50

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.

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);
+}