summaryrefslogtreecommitdiff
path: root/tests/status
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-11-05 16:07:07 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-11-05 16:22:01 +0100
commit5c54e2162a21cb909e961c62f53e7d4c64f80cb0 (patch)
tree6128e7ce82d0b8891bd469a652a67f7d6a403dc1 /tests/status
parent4bb8708730e81c551ca70f47ebd875f236e7998f (diff)
downloadlibgit2-5c54e2162a21cb909e961c62f53e7d4c64f80cb0.tar.gz
ignore: consider files with a CR in their namescmn/ignore-file-trailing-cr
We currently consider CR to start the end of the line, but that means that we miss cases with CR CR LF which can be used with git to match files whose names have CR at the end of their names. The fix from the patch comes from Russell's comment in the issue. This fixes #2536.
Diffstat (limited to 'tests/status')
-rw-r--r--tests/status/ignore.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/status/ignore.c b/tests/status/ignore.c
index b2af79074..7cf8803c2 100644
--- a/tests/status/ignore.c
+++ b/tests/status/ignore.c
@@ -883,3 +883,35 @@ void test_status_ignore__negative_ignores_without_trailing_slash_inside_ignores(
cl_assert(found_parent_child2_file);
}
+void test_status_ignore__filename_with_cr(void)
+{
+ int ignored;
+
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
+ cl_git_mkfile("empty_standard_repo/.gitignore", "Icon\r\r\n");
+
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Icon\r"));
+ cl_assert_equal_i(1, ignored);
+
+ cl_git_mkfile("empty_standard_repo/.gitignore", "Ico\rn\n");
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Ico\rn"));
+ cl_assert_equal_i(1, ignored);
+
+ cl_git_mkfile("empty_standard_repo/.gitignore", "Ico\rn\r\n");
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Ico\rn"));
+ cl_assert_equal_i(1, ignored);
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Ico\rn\r"));
+ cl_assert_equal_i(0, ignored);
+
+ cl_git_mkfile("empty_standard_repo/.gitignore", "Ico\rn\r\r\n");
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Ico\rn\r"));
+ cl_assert_equal_i(1, ignored);
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Icon\r"));
+ cl_assert_equal_i(0, ignored);
+
+ cl_git_mkfile("empty_standard_repo/.gitignore", "Icon\r\n");
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Icon\r"));
+ cl_assert_equal_i(0, ignored);
+ cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "Icon"));
+ cl_assert_equal_i(1, ignored);
+}