summaryrefslogtreecommitdiff
path: root/tests/attr
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-07-10 09:36:19 +0200
committerPatrick Steinhardt <ps@pks.im>2017-08-25 18:00:34 +0200
commit2d9ff8f5dc39ccb44a09365d19e216dff7eb3736 (patch)
tree864db6c50001a517623edd266be9ef38a7def6ff /tests/attr
parent38b44c3b360e9831178f2a8b21afbd6d1b6990df (diff)
downloadlibgit2-2d9ff8f5dc39ccb44a09365d19e216dff7eb3736.tar.gz
ignore: honor case insensitivity for negative ignores
When computing negative ignores, we throw away any rule which does not undo a previous rule to optimize. But on case insensitive file systems, we need to keep in mind that a negative ignore can also undo a previous rule with different case, which we did not yet honor while determining whether a rule undoes a previous one. So in the following example, we fail to unignore the "/Case" directory: /case !/Case Make both paths checking whether a plain- or wildcard-based rule undo a previous rule aware of case-insensitivity. This fixes the described issue.
Diffstat (limited to 'tests/attr')
-rw-r--r--tests/attr/ignore.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/attr/ignore.c b/tests/attr/ignore.c
index 5adfaf557..856e61f90 100644
--- a/tests/attr/ignore.c
+++ b/tests/attr/ignore.c
@@ -312,3 +312,37 @@ void test_attr_ignore__unignore_dir_succeeds(void)
assert_is_ignored(false, "src/foo.c");
assert_is_ignored(true, "src/foo/foo.c");
}
+
+void test_attr_ignore__case_insensitive_unignores_previous_rule(void)
+{
+ git_config *cfg;
+
+ cl_git_rewritefile("attr/.gitignore",
+ "/case\n"
+ "!/Case/\n");
+
+ cl_git_pass(git_repository_config(&cfg, g_repo));
+ cl_git_pass(git_config_set_bool(cfg, "core.ignorecase", true));
+
+ cl_must_pass(p_mkdir("attr/case", 0755));
+ cl_git_mkfile("attr/case/file", "content");
+
+ assert_is_ignored(false, "case/file");
+}
+
+void test_attr_ignore__case_sensitive_unignore_does_nothing(void)
+{
+ git_config *cfg;
+
+ cl_git_rewritefile("attr/.gitignore",
+ "/case\n"
+ "!/Case/\n");
+
+ cl_git_pass(git_repository_config(&cfg, g_repo));
+ cl_git_pass(git_config_set_bool(cfg, "core.ignorecase", false));
+
+ cl_must_pass(p_mkdir("attr/case", 0755));
+ cl_git_mkfile("attr/case/file", "content");
+
+ assert_is_ignored(true, "case/file");
+}