Commit 0798b014 by Carlos Martín Nieto

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.
parent b4e5432f
......@@ -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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment