]> git.proxmox.com Git - libgit2.git/blobdiff - tests/filter/crlf.c
New upstream version 0.28.1+dfsg.1
[libgit2.git] / tests / filter / crlf.c
index a8ebd949f384274e500dbc9d4d0468b04e2bc0c0..a266005d4de325fe42df74afe57b204e151dc7bb 100644 (file)
@@ -41,7 +41,7 @@ void test_filter_crlf__to_worktree(void)
        cl_assert_equal_s("Some text\r\nRight here\r\n", out.ptr);
 
        git_filter_list_free(fl);
-       git_buf_free(&out);
+       git_buf_dispose(&out);
 }
 
 void test_filter_crlf__to_odb(void)
@@ -66,7 +66,7 @@ void test_filter_crlf__to_odb(void)
        cl_assert_equal_s("Some text\nRight here\n", out.ptr);
 
        git_filter_list_free(fl);
-       git_buf_free(&out);
+       git_buf_dispose(&out);
 }
 
 void test_filter_crlf__with_safecrlf(void)
@@ -97,17 +97,24 @@ void test_filter_crlf__with_safecrlf(void)
        in.size = strlen(in.ptr);
 
        cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in));
-       cl_assert_equal_i(giterr_last()->klass, GITERR_FILTER);
+       cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_FILTER);
 
-       /* Normalized \n is reversible, so does not fail with safecrlf */
+       /* Normalized \n fails for autocrlf=true when safecrlf=true */
        in.ptr = "Normal\nLF\nonly\nline-endings.\n";
        in.size = strlen(in.ptr);
 
+       cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in));
+       cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_FILTER);
+
+       /* String with \r but without \r\n does not fail with safecrlf */
+       in.ptr = "Normal\nCR only\rand some more\nline-endings.\n";
+       in.size = strlen(in.ptr);
+
        cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
-       cl_assert_equal_s(in.ptr, out.ptr);
+       cl_assert_equal_s("Normal\nCR only\rand some more\nline-endings.\n", out.ptr);
 
        git_filter_list_free(fl);
-       git_buf_free(&out);
+       git_buf_dispose(&out);
 }
 
 void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
@@ -150,7 +157,7 @@ void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
        cl_assert_equal_s("Normal\nLF\nonly\nline-endings.\n", out.ptr);
 
        git_filter_list_free(fl);
-       git_buf_free(&out);
+       git_buf_dispose(&out);
 }
 
 void test_filter_crlf__no_safecrlf(void)
@@ -189,7 +196,7 @@ void test_filter_crlf__no_safecrlf(void)
        cl_assert_equal_s("Normal\nLF\nonly\nline-endings.\n", out.ptr);
 
        git_filter_list_free(fl);
-       git_buf_free(&out);
+       git_buf_dispose(&out);
 }
 
 void test_filter_crlf__safecrlf_warn(void)
@@ -231,5 +238,5 @@ void test_filter_crlf__safecrlf_warn(void)
        cl_assert_equal_s(in.ptr, out.ptr);
 
        git_filter_list_free(fl);
-       git_buf_free(&out);
+       git_buf_dispose(&out);
 }