crlf tests: ensure that Unix obeys autocrlf=true All platforms do terrible, horrible, no good, very bad translation when core.autocrlf=true. It's not just Windows!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 8d45c18..2cf3af3 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -220,11 +220,7 @@ void test_checkout_crlf__detect_crlf_autocrlf_true(void)
git_checkout_head(g_repo, &opts);
- if (GIT_EOL_NATIVE == GIT_EOL_LF)
- check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
- else
- check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
-
+ check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
}
@@ -238,16 +234,8 @@ void test_checkout_crlf__detect_crlf_autocrlf_true_utf8(void)
git_repository_set_head(g_repo, "refs/heads/master");
git_checkout_head(g_repo, &opts);
- if (GIT_EOL_NATIVE == GIT_EOL_LF)
- {
- check_file_contents("./crlf/few-utf8-chars-lf", FEW_UTF8_LF_RAW);
- check_file_contents("./crlf/many-utf8-chars-lf", MANY_UTF8_LF_RAW);
- }
- else
- {
- check_file_contents("./crlf/few-utf8-chars-lf", FEW_UTF8_CRLF_RAW);
- check_file_contents("./crlf/many-utf8-chars-lf", MANY_UTF8_CRLF_RAW);
- }
+ check_file_contents("./crlf/few-utf8-chars-lf", FEW_UTF8_CRLF_RAW);
+ check_file_contents("./crlf/many-utf8-chars-lf", MANY_UTF8_CRLF_RAW);
check_file_contents("./crlf/few-utf8-chars-crlf", FEW_UTF8_CRLF_RAW);
check_file_contents("./crlf/many-utf8-chars-crlf", MANY_UTF8_CRLF_RAW);
@@ -269,10 +257,7 @@ void test_checkout_crlf__autocrlf_true_index_size_is_filtered_size(void)
cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL);
- if (GIT_EOL_NATIVE == GIT_EOL_LF)
- cl_assert_equal_sz(strlen(ALL_LF_TEXT_RAW), entry->file_size);
- else
- cl_assert_equal_sz(strlen(ALL_LF_TEXT_AS_CRLF), entry->file_size);
+ cl_assert_equal_sz(strlen(ALL_LF_TEXT_AS_CRLF), entry->file_size);
cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL);
cl_assert_equal_sz(strlen(ALL_CRLF_TEXT_RAW), entry->file_size);
@@ -341,25 +326,14 @@ void test_checkout_crlf__with_ident(void)
git_checkout_head(g_repo, &opts);
- if (GIT_EOL_NATIVE == GIT_EOL_LF) {
- cl_assert_equal_file(
- ALL_LF_TEXT_RAW
- "\n$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467 $\n",
- 0, "crlf/lf.ident");
- cl_assert_equal_file(
- ALL_CRLF_TEXT_AS_LF
- "\n$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857 $\n\n",
- 0, "crlf/crlf.ident");
- } else {
- cl_assert_equal_file(
- ALL_LF_TEXT_AS_CRLF
- "\r\n$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467 $\r\n",
- 0, "crlf/lf.ident");
- cl_assert_equal_file(
- ALL_CRLF_TEXT_RAW
- "\r\n$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857 $\r\n\r\n",
- 0, "crlf/crlf.ident");
- }
+ cl_assert_equal_file(
+ ALL_LF_TEXT_AS_CRLF
+ "\r\n$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467 $\r\n",
+ 0, "crlf/lf.ident");
+ cl_assert_equal_file(
+ ALL_CRLF_TEXT_RAW
+ "\r\n$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857 $\r\n\r\n",
+ 0, "crlf/crlf.ident");
cl_assert_equal_file(
"$Id: f7830382dac1f1583422be5530fdfbd26289431b $\n"
@@ -394,13 +368,8 @@ void test_checkout_crlf__autocrlf_true_no_attrs(void)
git_checkout_head(g_repo, &opts);
- if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
- check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
- check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
- } else {
- check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
- check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
- }
+ check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
+ check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
}
void test_checkout_crlf__autocrlf_input_no_attrs(void)
@@ -447,13 +416,8 @@ void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
git_checkout_head(g_repo, &opts);
- if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
- check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
- check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
- } else {
- check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
- check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
- }
+ check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
+ check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
}
void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
@@ -483,10 +447,7 @@ void test_checkout_crlf__can_write_empty_file(void)
check_file_contents("./crlf/test1.txt", "");
- if (GIT_EOL_NATIVE == GIT_EOL_LF)
- check_file_contents("./crlf/test2.txt", "test2.txt's content\n");
- else
- check_file_contents("./crlf/test2.txt", "test2.txt's content\r\n");
+ check_file_contents("./crlf/test2.txt", "test2.txt's content\r\n");
check_file_contents("./crlf/test3.txt", "");
}
diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c
index 406d3b6..a8ebd94 100644
--- a/tests/filter/crlf.c
+++ b/tests/filter/crlf.c
@@ -38,11 +38,7 @@ void test_filter_crlf__to_worktree(void)
cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
-#ifdef GIT_WIN32
cl_assert_equal_s("Some text\r\nRight here\r\n", out.ptr);
-#else
- cl_assert_equal_s("Some text\nRight here\n", out.ptr);
-#endif
git_filter_list_free(fl);
git_buf_free(&out);