Fix C4297 warning: 'function' : function assumed not to throw an exception but does
[TortoiseGit.git] / ext / libgit2-0006-Make-checking-out-files-behave-like-vanilla-git-conc.patch
blob874f305f523046544cc684b45748bc958eb3ead9
1 From 769c2d713952de107cf0325de3ddd2531072e849 Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Tue, 3 Mar 2015 17:51:18 +0100
4 Subject: [PATCH 6/6] Make checking out files behave like vanilla git
5 concerning CRLF filter
7 This also fixes
8 * files with mixed line endings and AutoCrLf enabled
9 * core.autocrlf=true and "* text eol=crlf" on LF-only platforms
11 Signed-off-by: Sven Strickroth <email@cs-ware.de>
12 ---
13 CHANGELOG.md | 7 +
14 src/buf_text.c | 14 +-
15 src/crlf.c | 39 +-
16 tests/checkout/crlf.c | 888 +++++++++++++++++++--
17 tests/core/buffer.c | 24 +-
18 tests/filter/crlf.c | 4 -
19 tests/filter/crlf.h | 6 +
20 .../16/78031ee023a23bd3515e4e1693b661a69f0a73 | Bin 0 -> 193 bytes
21 .../20/3555c5676d75cd80d69b50beb1f4b588c59ceb | Bin 0 -> 36 bytes
22 .../41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41 | Bin 0 -> 36 bytes
23 .../69/597764abeaa1a403ebf589d2ea579c6a8f877e | Bin 0 -> 170 bytes
24 .../85/340755cfe5e28c2835781978bb1cece91b3d0f | Bin 0 -> 37 bytes
25 .../92/0e90a663bea5d740989d5f935f6dfb473a0c5d | Bin 0 -> 303 bytes
26 .../aa/f083a9cb53dac3669dcfa0e48921580d629ec7 | Bin 0 -> 37 bytes
27 .../af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3 | Bin 0 -> 36 bytes
28 .../d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4 | Bin 0 -> 35 bytes
29 .../de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd | Bin 0 -> 179 bytes
30 tests/resources/crlf/.gitted/refs/heads/master | Bin 42 -> 41 bytes
31 18 files changed, 877 insertions(+), 105 deletions(-)
32 create mode 100644 tests/resources/crlf/.gitted/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73
33 create mode 100644 tests/resources/crlf/.gitted/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb
34 create mode 100644 tests/resources/crlf/.gitted/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41
35 create mode 100644 tests/resources/crlf/.gitted/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e
36 create mode 100644 tests/resources/crlf/.gitted/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f
37 create mode 100644 tests/resources/crlf/.gitted/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d
38 create mode 100644 tests/resources/crlf/.gitted/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7
39 create mode 100644 tests/resources/crlf/.gitted/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3
40 create mode 100644 tests/resources/crlf/.gitted/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4
41 create mode 100644 tests/resources/crlf/.gitted/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd
43 diff --git a/CHANGELOG.md b/CHANGELOG.md
44 index 881dca4..d9f695d 100644
45 --- a/CHANGELOG.md
46 +++ b/CHANGELOG.md
47 @@ -16,6 +16,13 @@ v0.22 + 1
48 * especially files containing single CR chars are added as is now
49 * honor "text" attribute for forcing a file being interpreted as text
51 +* LF -> CRLF filter now handles files on checkout the way vanilla git does
52 + * honor "text" attribute forcing the processing of binary files and eol=crlf processing on LF platforms
53 + * skip files containing the same number of LF and CRLF eols
54 + * fix binary detection (only apply it for AUTO and GUESS files)
55 + * correctly handle files with mixed line endings (CR, LF and also CrLf at the same time and in different combinations)
56 + * fix checking out with core.autocrlf=true on LF-only platforms
58 * Rename and copy detection is enabled for small files.
60 * Checkout can now handle an initial checkout of a repository, making
61 diff --git a/src/buf_text.c b/src/buf_text.c
62 index 864e39c..c338160 100644
63 --- a/src/buf_text.c
64 +++ b/src/buf_text.c
65 @@ -131,17 +131,17 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src)
66 for (; next; scan = next + 1, next = memchr(scan, '\n', end - scan)) {
67 size_t copylen = next - scan;
69 - /* if we find mixed line endings, bail */
70 - if (next > start && next[-1] == '\r') {
71 - git_buf_free(tgt);
72 - return GIT_PASSTHROUGH;
73 - }
75 GITERR_CHECK_ALLOC_ADD(&alloclen, copylen, 3);
76 if (git_buf_grow_by(tgt, alloclen) < 0)
77 return -1;
79 - if (next > scan) {
80 + /* if we find mixed line endings, ignore it as vanilla git does
81 + * the decision if this function needs to be called at all is made in the crlf filter
82 + */
83 + if (next > start && next[-1] == '\r') {
84 + memcpy(tgt->ptr + tgt->size, scan, copylen - 1);
85 + tgt->size += copylen - 1;
86 + } else if (next > scan) {
87 memcpy(tgt->ptr + tgt->size, scan, copylen);
88 tgt->size += copylen;
90 diff --git a/src/crlf.c b/src/crlf.c
91 index eef8b5f..e4a4963 100644
92 --- a/src/crlf.c
93 +++ b/src/crlf.c
94 @@ -227,6 +227,10 @@ static const char *line_ending(struct crlf_attrs *ca)
96 switch (ca->eol) {
97 case GIT_EOL_UNSET:
98 + if (ca->auto_crlf == GIT_AUTO_CRLF_TRUE)
99 + return "\r\n";
100 + if (ca->auto_crlf == GIT_AUTO_CRLF_INPUT)
101 + return "\n";
102 return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n";
104 case GIT_EOL_CRLF:
105 @@ -248,24 +252,49 @@ static int crlf_apply_to_workdir(
106 struct crlf_attrs *ca, git_buf *to, const git_buf *from)
108 const char *workdir_ending = NULL;
109 + git_buf_text_stats stats;
110 + bool is_binary;
112 /* Empty file? Nothing to do. */
113 if (git_buf_len(from) == 0)
114 return 0;
116 - /* Don't filter binary files */
117 - if (git_buf_text_is_binary(from))
118 - return GIT_PASSTHROUGH;
120 /* Determine proper line ending */
121 workdir_ending = line_ending(ca);
122 if (!workdir_ending)
123 return -1;
125 - /* only LF->CRLF conversion is supported, do nothing on LF platforms */
126 + /* check if we need to consider a LF->CRLF conversation */
127 if (strcmp(workdir_ending, "\r\n") != 0)
128 return GIT_PASSTHROUGH;
130 + is_binary = git_buf_text_gather_stats(&stats, from, false);
132 + /* Nothing to convert */
133 + if (!stats.lf)
134 + return GIT_PASSTHROUGH;
136 + /* Is file already CRLF? */
137 + if (stats.lf == stats.crlf)
138 + return GIT_PASSTHROUGH;
140 + if (ca->crlf_action == GIT_CRLF_AUTO || ca->crlf_action == GIT_CRLF_GUESS) {
141 + if (ca->crlf_action == GIT_CRLF_GUESS) {
142 + /*
143 + * If the file in the index has any CR OR crlf in it, do not convert.
144 + */
145 + if (stats.cr || stats.crlf)
146 + return GIT_PASSTHROUGH;
149 + /* If we have any bare CR characters, we're not going to touch it */
150 + if (stats.cr != stats.crlf)
151 + return GIT_PASSTHROUGH;
153 + if (is_binary)
154 + return GIT_PASSTHROUGH;
157 return git_buf_text_lf_to_crlf(to, from);
160 diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
161 index a7a579e..78ddbea 100644
162 --- a/tests/checkout/crlf.c
163 +++ b/tests/checkout/crlf.c
164 @@ -18,7 +18,7 @@ void test_checkout_crlf__cleanup(void)
165 cl_git_sandbox_cleanup();
168 -void test_checkout_crlf__detect_crlf_autocrlf_false(void)
169 +void test_checkout_crlf__autocrlf_false(void)
171 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
172 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
173 @@ -29,6 +29,17 @@ void test_checkout_crlf__detect_crlf_autocrlf_false(void)
175 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
176 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
178 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
179 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
181 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
182 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
184 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
185 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
186 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
187 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
190 void test_checkout_crlf__autocrlf_false_index_size_is_unfiltered_size(void)
191 @@ -50,39 +61,34 @@ void test_checkout_crlf__autocrlf_false_index_size_is_unfiltered_size(void)
192 cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL);
193 cl_assert(entry->file_size == strlen(ALL_CRLF_TEXT_RAW));
195 - git_index_free(index);
197 + cl_assert((entry = git_index_get_bypath(index, "more-lf", 0)) != NULL);
198 + cl_assert(entry->file_size == strlen(MORE_LF_TEXT_RAW));
200 -void test_checkout_crlf__detect_crlf_autocrlf_true(void)
202 - git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
203 - opts.checkout_strategy = GIT_CHECKOUT_FORCE;
204 + cl_assert((entry = git_index_get_bypath(index, "more-crlf", 0)) != NULL);
205 + cl_assert(entry->file_size == strlen(MORE_CRLF_TEXT_RAW));
207 - cl_repo_set_bool(g_repo, "core.autocrlf", true);
208 + cl_assert((entry = git_index_get_bypath(index, "mixed-lf-cr", 0)) != NULL);
209 + cl_assert(entry->file_size == strlen(MIXED_LF_CR_RAW));
211 - git_checkout_head(g_repo, &opts);
212 + cl_assert((entry = git_index_get_bypath(index, "mixed-lf-cr-crlf", 0)) != NULL);
213 + cl_assert(entry->file_size == strlen(MIXED_LF_CR_CRLF_RAW));
215 - if (GIT_EOL_NATIVE == GIT_EOL_LF)
216 - check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
217 - else
218 - check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
219 + cl_assert((entry = git_index_get_bypath(index, "binary-all-lf", 0)) != NULL);
220 + cl_assert(entry->file_size == strlen(BINARY_ALL_LF_TEXT_RAW));
222 - check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
224 + cl_assert((entry = git_index_get_bypath(index, "binary-all-crlf", 0)) != NULL);
225 + cl_assert(entry->file_size == strlen(BINARY_ALL_CRLF_TEXT_RAW));
227 -void test_checkout_crlf__more_lf_autocrlf_true(void)
229 - git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
230 - opts.checkout_strategy = GIT_CHECKOUT_FORCE;
232 - cl_repo_set_bool(g_repo, "core.autocrlf", true);
233 + cl_assert((entry = git_index_get_bypath(index, "binary-mixed-lf-cr", 0)) != NULL);
234 + cl_assert(entry->file_size == strlen(BINARY_MIXED_LF_CR_RAW));
236 - git_checkout_head(g_repo, &opts);
237 + cl_assert((entry = git_index_get_bypath(index, "binary-mixed-lf-cr-crlf", 0)) != NULL);
238 + cl_assert(entry->file_size == strlen(BINARY_MIXED_LF_CR_CRLF_RAW));
240 - check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
241 + git_index_free(index);
244 -void test_checkout_crlf__more_crlf_autocrlf_true(void)
245 +void test_checkout_crlf__autocrlf_true(void)
247 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
248 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
249 @@ -91,19 +97,19 @@ void test_checkout_crlf__more_crlf_autocrlf_true(void)
251 git_checkout_head(g_repo, &opts);
253 - check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
256 -void test_checkout_crlf__all_crlf_autocrlf_true(void)
258 - git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
259 - opts.checkout_strategy = GIT_CHECKOUT_FORCE;
260 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
261 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
263 - cl_repo_set_bool(g_repo, "core.autocrlf", true);
264 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
265 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
267 - git_checkout_head(g_repo, &opts);
268 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
269 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
271 - check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
272 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
273 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
274 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
275 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
278 void test_checkout_crlf__detect_crlf_autocrlf_true_utf8(void)
279 @@ -116,16 +122,8 @@ void test_checkout_crlf__detect_crlf_autocrlf_true_utf8(void)
280 git_repository_set_head(g_repo, "refs/heads/utf8");
281 git_checkout_head(g_repo, &opts);
283 - if (GIT_EOL_NATIVE == GIT_EOL_LF)
285 - check_file_contents("./crlf/few-utf8-chars-lf.txt", FEW_UTF8_LF_RAW);
286 - check_file_contents("./crlf/many-utf8-chars-lf.txt", MANY_UTF8_LF_RAW);
288 - else
290 - check_file_contents("./crlf/few-utf8-chars-lf.txt", FEW_UTF8_CRLF_RAW);
291 - check_file_contents("./crlf/many-utf8-chars-lf.txt", MANY_UTF8_CRLF_RAW);
293 + check_file_contents("./crlf/few-utf8-chars-lf.txt", FEW_UTF8_CRLF_RAW);
294 + check_file_contents("./crlf/many-utf8-chars-lf.txt", MANY_UTF8_CRLF_RAW);
296 check_file_contents("./crlf/few-utf8-chars-crlf.txt", FEW_UTF8_CRLF_RAW);
297 check_file_contents("./crlf/many-utf8-chars-crlf.txt", MANY_UTF8_CRLF_RAW);
298 @@ -145,11 +143,7 @@ void test_checkout_crlf__autocrlf_true_index_size_is_filtered_size(void)
299 git_repository_index(&index, g_repo);
301 cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL);
303 - if (GIT_EOL_NATIVE == GIT_EOL_LF)
304 - cl_assert_equal_sz(strlen(ALL_LF_TEXT_RAW), entry->file_size);
305 - else
306 - cl_assert_equal_sz(strlen(ALL_LF_TEXT_AS_CRLF), entry->file_size);
307 + cl_assert_equal_sz(strlen(ALL_LF_TEXT_AS_CRLF), entry->file_size);
309 cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL);
310 cl_assert_equal_sz(strlen(ALL_CRLF_TEXT_RAW), entry->file_size);
311 @@ -218,25 +212,14 @@ void test_checkout_crlf__with_ident(void)
313 git_checkout_head(g_repo, &opts);
315 - if (GIT_EOL_NATIVE == GIT_EOL_LF) {
316 - cl_assert_equal_file(
317 - ALL_LF_TEXT_RAW
318 - "\n$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467$\n",
319 - 0, "crlf/lf.ident");
320 - cl_assert_equal_file(
321 - ALL_CRLF_TEXT_AS_LF
322 - "\n$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857$\n\n",
323 - 0, "crlf/crlf.ident");
324 - } else {
325 - cl_assert_equal_file(
326 - ALL_LF_TEXT_AS_CRLF
327 - "\r\n$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467$\r\n",
328 - 0, "crlf/lf.ident");
329 - cl_assert_equal_file(
330 - ALL_CRLF_TEXT_RAW
331 - "\r\n$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857$\r\n\r\n",
332 - 0, "crlf/crlf.ident");
334 + cl_assert_equal_file(
335 + ALL_LF_TEXT_AS_CRLF
336 + "\r\n$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467$\r\n",
337 + 0, "crlf/lf.ident");
338 + cl_assert_equal_file(
339 + ALL_CRLF_TEXT_RAW
340 + "\r\n$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857$\r\n\r\n",
341 + 0, "crlf/crlf.ident");
343 cl_assert_equal_file(
344 "$Id: f7830382dac1f1583422be5530fdfbd26289431b$\n"
345 @@ -249,51 +232,124 @@ void test_checkout_crlf__with_ident(void)
346 git_index_free(index);
349 -void test_checkout_crlf__autocrlf_false_no_attrs(void)
350 +void test_checkout_crlf__autocrlf_input(void)
352 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
353 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
355 - cl_repo_set_bool(g_repo, "core.autocrlf", false);
356 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
358 git_checkout_head(g_repo, &opts);
360 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
361 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
363 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
364 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
366 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
367 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
369 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
370 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
371 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
372 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
375 -void test_checkout_crlf__autocrlf_true_no_attrs(void)
376 +void test_checkout_crlf__autocrlf_false__text_attr(void)
378 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
379 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
381 - cl_repo_set_bool(g_repo, "core.autocrlf", true);
382 + cl_git_mkfile("./crlf/.gitattributes", "* text\n");
384 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
386 git_checkout_head(g_repo, &opts);
388 if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
389 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
390 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
392 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
393 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
395 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
396 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
398 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
399 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
400 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
401 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
402 } else {
403 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
404 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
406 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
407 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
409 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
410 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
412 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
413 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
414 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
415 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
419 -void test_checkout_crlf__autocrlf_input_no_attrs(void)
420 +void test_checkout_crlf__autocrlf_true__text_attr(void)
422 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
423 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
425 + cl_git_mkfile("./crlf/.gitattributes", "* text\n");
427 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
429 + git_checkout_head(g_repo, &opts);
431 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
432 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
433 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
434 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
436 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
437 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
439 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
440 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
441 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
442 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
445 +void test_checkout_crlf__autocrlf_input__text_attr(void)
447 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
448 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
450 + cl_git_mkfile("./crlf/.gitattributes", "* text\n");
452 cl_repo_set_string(g_repo, "core.autocrlf", "input");
454 git_checkout_head(g_repo, &opts);
456 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
457 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
459 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
460 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
462 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
463 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
465 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
466 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
467 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
468 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
471 -void test_checkout_crlf__autocrlf_false_text_auto_attr(void)
472 +void test_checkout_crlf__autocrlf_false__text_auto_attr(void)
474 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
475 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
476 @@ -307,13 +363,27 @@ void test_checkout_crlf__autocrlf_false_text_auto_attr(void)
477 if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
478 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
479 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
481 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
482 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
483 } else {
484 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
485 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
487 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
488 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
491 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
492 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
494 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
495 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
496 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
497 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
500 -void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
501 +void test_checkout_crlf__autocrlf_true__text_auto_attr(void)
503 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
504 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
505 @@ -324,21 +394,432 @@ void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
507 git_checkout_head(g_repo, &opts);
509 - if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
510 - check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
511 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
512 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
513 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
514 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
516 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
517 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
519 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
520 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
521 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
522 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
525 +void test_checkout_crlf__autocrlf_input__text_auto_attr(void)
527 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
528 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
530 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto\n");
532 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
534 + git_checkout_head(g_repo, &opts);
536 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
537 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
539 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
540 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
542 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
543 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
545 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
546 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
547 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
548 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
551 +void test_checkout_crlf__autocrlf_false__text__eol_crlf_attr(void)
553 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
554 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
556 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=crlf\n");
558 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
560 + git_checkout_head(g_repo, &opts);
562 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
563 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
565 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
566 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
568 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
569 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
571 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
572 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
573 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
574 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
577 +void test_checkout_crlf__autocrlf_true__text__eol_crlf_attr(void)
579 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
580 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
582 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=crlf\n");
584 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
586 + git_checkout_head(g_repo, &opts);
588 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
589 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
591 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
592 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
594 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
595 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
597 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
598 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
599 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
600 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
603 +void test_checkout_crlf__autocrlf_input__text__eol_crlf_attr(void)
605 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
606 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
608 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=crlf\n");
610 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
612 + git_checkout_head(g_repo, &opts);
614 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
615 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
617 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
618 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
620 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
621 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
623 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
624 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
625 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
626 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
629 +void test_checkout_crlf__autocrlf_false__text__eol_lf_attr(void)
631 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
632 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
634 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=lf\n");
636 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
638 + git_checkout_head(g_repo, &opts);
640 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
641 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
643 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
644 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
646 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
647 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
649 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
650 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
651 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
652 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
655 +void test_checkout_crlf__autocrlf_true__text__eol_lf_attr(void)
657 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
658 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
660 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=lf\n");
662 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
664 + git_checkout_head(g_repo, &opts);
666 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
667 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
669 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
670 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
672 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
673 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
675 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
676 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
677 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
678 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
681 +void test_checkout_crlf__autocrlf_input__text__eol_lf_attr(void)
683 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
684 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
686 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=lf\n");
688 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
690 + git_checkout_head(g_repo, &opts);
692 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
693 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
695 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
696 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
698 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
699 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
701 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
702 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
703 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
704 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
707 +void test_checkout_crlf__autocrlf_false__eol_lf_attr(void)
709 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
710 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
712 + cl_git_mkfile("./crlf/.gitattributes", "* eol=lf\n");
714 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
716 + git_checkout_head(g_repo, &opts);
718 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
719 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
721 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
722 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
724 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
725 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
727 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
728 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
729 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
730 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
733 +void test_checkout_crlf__autocrlf_true__eol_lf_attr(void)
735 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
736 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
738 + cl_git_mkfile("./crlf/.gitattributes", "* eol=lf\n");
740 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
742 + git_checkout_head(g_repo, &opts);
744 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
745 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
747 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
748 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
750 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
751 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
753 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
754 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
755 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
756 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
759 +void test_checkout_crlf__autocrlf_input__eol_lf_attr(void)
761 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
762 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
764 + cl_git_mkfile("./crlf/.gitattributes", "* eol=lf\n");
766 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
768 + git_checkout_head(g_repo, &opts);
770 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
771 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
773 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
774 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
776 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
777 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
779 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
780 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
781 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
782 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
785 +void test_checkout_crlf__autocrlf_false__eol_crlf_attr(void)
787 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
788 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
790 + cl_git_mkfile("./crlf/.gitattributes", "* eol=crlf\n");
792 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
794 + git_checkout_head(g_repo, &opts);
796 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
797 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
799 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
800 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
802 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
803 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
805 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
806 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
807 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
808 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
811 +void test_checkout_crlf__autocrlf_true__eol_crlf_attr(void)
813 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
814 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
816 + cl_git_mkfile("./crlf/.gitattributes", "* eol=crlf\n");
818 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
820 + git_checkout_head(g_repo, &opts);
822 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
823 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
825 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
826 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
828 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
829 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
831 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
832 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
833 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
834 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
837 +void test_checkout_crlf__autocrlf_input__eol_crlf_attr(void)
839 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
840 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
842 + cl_git_mkfile("./crlf/.gitattributes", "* eol=crlf\n");
844 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
846 + git_checkout_head(g_repo, &opts);
848 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
849 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
851 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
852 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
854 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
855 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
857 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
858 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
859 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
860 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
863 +void test_checkout_crlf__autocrlf_false__crlf_attr(void)
865 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
866 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
868 + cl_git_mkfile("./crlf/.gitattributes", "* crlf\n");
870 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
872 + git_checkout_head(g_repo, &opts);
874 + if (GIT_EOL_NATIVE == GIT_EOL_LF) {
875 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
876 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
878 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
879 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
881 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
882 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
884 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
885 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
886 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
887 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
888 } else {
889 - check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
890 - check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
891 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
892 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
894 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
895 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
897 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
898 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
900 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
901 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
902 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
903 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
907 -void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
908 +void test_checkout_crlf__autocrlf_true__crlf_attr(void)
910 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
911 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
913 - cl_git_mkfile("./crlf/.gitattributes", "* text=auto\n");
914 + cl_git_mkfile("./crlf/.gitattributes", "* crlf\n");
916 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
918 + git_checkout_head(g_repo, &opts);
920 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
921 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
923 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
924 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
926 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
927 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
929 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
930 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
931 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
932 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
935 +void test_checkout_crlf__autocrlf_input__crlf_attr(void)
937 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
938 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
940 + cl_git_mkfile("./crlf/.gitattributes", "* crlf\n");
942 cl_repo_set_string(g_repo, "core.autocrlf", "input");
944 @@ -346,4 +827,249 @@ void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
946 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
947 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
949 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
950 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
952 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
953 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
955 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
956 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
957 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
958 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
961 +void test_checkout_crlf__autocrlf_false__no_crlf_attr(void)
963 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
964 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
966 + cl_git_mkfile("./crlf/.gitattributes", "* -crlf\n");
968 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
970 + git_checkout_head(g_repo, &opts);
972 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
973 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
975 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
976 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
978 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
979 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
981 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
982 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
983 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
984 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
987 +void test_checkout_crlf__autocrlf_true__no_crlf_attr(void)
989 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
990 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
992 + cl_git_mkfile("./crlf/.gitattributes", "* -crlf\n");
994 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
996 + git_checkout_head(g_repo, &opts);
998 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
999 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
1001 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
1002 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
1004 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
1005 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
1007 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
1008 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
1009 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
1010 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
1013 +void test_checkout_crlf__autocrlf_input__no_crlf_attr(void)
1015 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1016 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1018 + cl_git_mkfile("./crlf/.gitattributes", "* -crlf\n");
1020 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
1022 + git_checkout_head(g_repo, &opts);
1024 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
1025 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
1027 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
1028 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
1030 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
1031 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
1033 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
1034 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
1035 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
1036 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
1039 +void test_checkout_crlf__autocrlf_false__text_auto__eol_lf_attr(void)
1041 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1042 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1044 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto eol=lf\n");
1046 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
1048 + git_checkout_head(g_repo, &opts);
1050 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
1051 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
1053 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
1054 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
1056 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
1057 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
1059 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
1060 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
1061 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
1062 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
1065 +void test_checkout_crlf__autocrlf_true__text_auto__eol_lf_attr(void)
1067 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1068 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1070 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto eol=lf\n");
1072 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
1074 + git_checkout_head(g_repo, &opts);
1076 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
1077 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
1079 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
1080 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
1082 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
1083 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
1085 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
1086 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
1087 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
1088 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
1091 +void test_checkout_crlf__autocrlf_input__text_auto__eol_lf_attr(void)
1093 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1094 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1096 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto eol=lf\n");
1098 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
1100 + git_checkout_head(g_repo, &opts);
1102 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
1103 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
1105 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
1106 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
1108 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
1109 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
1111 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
1112 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
1113 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
1114 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
1117 +void test_checkout_crlf__autocrlf_false_text_auto__eol_crlf_attr(void)
1119 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1120 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1122 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto eol=crlf\n");
1124 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
1126 + git_checkout_head(g_repo, &opts);
1128 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
1129 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
1131 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
1132 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
1134 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
1135 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
1137 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
1138 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
1139 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
1140 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
1143 +void test_checkout_crlf__autocrlf_true_text_auto__eol_crlf_attr(void)
1145 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1146 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1148 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto eol=crlf\n");
1150 + cl_repo_set_bool(g_repo, "core.autocrlf", true);
1152 + git_checkout_head(g_repo, &opts);
1154 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
1155 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
1157 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
1158 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
1160 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
1161 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
1163 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
1164 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
1165 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
1166 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
1169 +void test_checkout_crlf__autocrlf_input_text_auto__eol_crlf_attr(void)
1171 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
1172 + opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1174 + cl_git_mkfile("./crlf/.gitattributes", "* text=auto eol=crlf\n");
1176 + cl_repo_set_string(g_repo, "core.autocrlf", "input");
1178 + git_checkout_head(g_repo, &opts);
1180 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
1181 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
1183 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
1184 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
1186 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
1187 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
1189 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
1190 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
1191 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
1192 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
1194 diff --git a/tests/core/buffer.c b/tests/core/buffer.c
1195 index d28aa21..67ab560 100644
1196 --- a/tests/core/buffer.c
1197 +++ b/tests/core/buffer.c
1198 @@ -1054,14 +1054,16 @@ void test_core_buffer__lf_and_crlf_conversions(void)
1200 git_buf_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
1202 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1203 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1204 + check_buf("crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n", tgt);
1206 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1207 check_buf("crlf\ncrlf\ncrlf\ncrlf\n", tgt);
1209 git_buf_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
1211 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1212 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1213 + check_buf("\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf", tgt);
1215 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1216 check_buf("\ncrlf\ncrlf\ncrlf\ncrlf\ncrlf", tgt);
1217 @@ -1070,7 +1072,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
1219 git_buf_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
1221 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1222 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1223 + check_buf("\r\nlf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\ncrlf\r\n", tgt);
1224 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1225 check_buf("\nlf\nlf\ncrlf\nlf\nlf\ncrlf\n", tgt);
1227 @@ -1078,7 +1081,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
1229 git_buf_sets(&src, "\ncrlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf");
1231 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1232 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1233 + check_buf("\r\ncrlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf", tgt);
1234 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1235 check_buf("\ncrlf\ncrlf\nlf\ncrlf\ncrlf", tgt);
1237 @@ -1086,7 +1090,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
1239 git_buf_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
1241 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1242 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1243 + check_buf("\rcrlf\r\nlf\r\nlf\r\ncr\rcrlf\r\nlf\r\ncr\r", tgt);
1244 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1245 check_buf("\rcrlf\nlf\nlf\ncr\rcrlf\nlf\ncr\r", tgt);
1247 @@ -1102,7 +1107,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
1248 /* blob correspondence tests */
1250 git_buf_sets(&src, ALL_CRLF_TEXT_RAW);
1251 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1252 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1253 + check_buf(ALL_CRLF_TEXT_RAW, tgt);
1254 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1255 check_buf(ALL_CRLF_TEXT_AS_LF, tgt);
1256 git_buf_free(&src);
1257 @@ -1117,14 +1123,16 @@ void test_core_buffer__lf_and_crlf_conversions(void)
1258 git_buf_free(&tgt);
1260 git_buf_sets(&src, MORE_CRLF_TEXT_RAW);
1261 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1262 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1263 + check_buf(MORE_CRLF_TEXT_AS_CRLF, tgt);
1264 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1265 check_buf(MORE_CRLF_TEXT_AS_LF, tgt);
1266 git_buf_free(&src);
1267 git_buf_free(&tgt);
1269 git_buf_sets(&src, MORE_LF_TEXT_RAW);
1270 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
1271 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
1272 + check_buf(MORE_LF_TEXT_AS_CRLF, tgt);
1273 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
1274 check_buf(MORE_LF_TEXT_AS_LF, tgt);
1275 git_buf_free(&src);
1276 diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c
1277 index b81fbeb..d1bf7a4 100644
1278 --- a/tests/filter/crlf.c
1279 +++ b/tests/filter/crlf.c
1280 @@ -38,11 +38,7 @@ void test_filter_crlf__to_worktree(void)
1282 cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in));
1284 -#ifdef GIT_WIN32
1285 cl_assert_equal_s("Some text\r\nRight here\r\n", out.ptr);
1286 -#else
1287 - cl_assert_equal_s("Some text\nRight here\n", out.ptr);
1288 -#endif
1290 git_filter_list_free(fl);
1291 git_buf_free(&out);
1292 diff --git a/tests/filter/crlf.h b/tests/filter/crlf.h
1293 index 0a7a10d..bb13162 100644
1294 --- a/tests/filter/crlf.h
1295 +++ b/tests/filter/crlf.h
1296 @@ -11,6 +11,8 @@
1297 #define ALL_LF_TEXT_RAW "lf\nlf\nlf\nlf\nlf\n"
1298 #define MORE_CRLF_TEXT_RAW "crlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf\r\n"
1299 #define MORE_LF_TEXT_RAW "lf\nlf\ncrlf\r\nlf\nlf\n"
1300 +#define MIXED_LF_CR_RAW "one\ntwo\rthree\nfour\r"
1301 +#define MIXED_LF_CR_CRLF_RAW "one\ntwo\rthree\r\nfour\r"
1302 #define BINARY_ALL_CRLF_TEXT_RAW "\01one\r\ntwo\r\nthree\r\nfour\r\n"
1303 #define BINARY_ALL_LF_TEXT_RAW "\01one\ntwo\nthree\nfour\n"
1304 #define BINARY_MIXED_LF_CR_RAW "\01" MIXED_LF_CR_RAW
1305 @@ -20,6 +22,8 @@
1306 #define ALL_LF_TEXT_AS_CRLF "lf\r\nlf\r\nlf\r\nlf\r\nlf\r\n"
1307 #define MORE_CRLF_TEXT_AS_CRLF "crlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf\r\n"
1308 #define MORE_LF_TEXT_AS_CRLF "lf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\n"
1309 +#define MIXED_LF_CR_AS_CRLF "one\r\ntwo\rthree\r\nfour\r"
1310 +#define MIXED_LF_CR_CRLF_AS_CRLF MIXED_LF_CR_AS_CRLF
1311 #define BINARY_ALL_CRLF_TEXT_AS_CRLF BINARY_ALL_CRLF_TEXT_RAW
1312 #define BINARY_ALL_LF_TEXT_AS_CRLF BINARY_ALL_CRLF_TEXT_AS_CRLF
1313 #define BINARY_MIXED_LF_CR_AS_CRLF "\01" MIXED_LF_CR_AS_CRLF
1314 @@ -29,6 +33,8 @@
1315 #define ALL_LF_TEXT_AS_LF ALL_LF_TEXT_RAW
1316 #define MORE_CRLF_TEXT_AS_LF "crlf\ncrlf\nlf\ncrlf\ncrlf\n"
1317 #define MORE_LF_TEXT_AS_LF "lf\nlf\ncrlf\nlf\nlf\n"
1318 +#define MIXED_LF_CR_AS_LF MIXED_LF_CR_RAW
1319 +#define MIXED_LF_CR_CRLF_AS_LF MIXED_LF_CR_CRLF_RAW
1320 #define BINARY_ALL_CRLF_TEXT_AS_LF BINARY_ALL_CRLF_TEXT_RAW
1321 #define BINARY_ALL_LF_TEXT_AS_LF BINARY_ALL_LF_TEXT_RAW
1322 #define BINARY_MIXED_LF_CR_AS_LF BINARY_MIXED_LF_CR_RAW
1323 diff --git a/tests/resources/crlf/.gitted/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73 b/tests/resources/crlf/.gitted/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73
1324 new file mode 100644
1325 index 0000000000000000000000000000000000000000..4aa4ffb1d6714929c6a392d9e09de3644ba8cdc6
1326 GIT binary patch
1327 literal 193
1328 zcmV;y06zbC0V^p=O;s>5GG#C{FfcPQQAo_m(M>MONn=>K=*2`E*?k&9zm7iJ@?go{
1329 zSl-AqBsD-4mD39@p8t{_ytH=vf;7?DVFI`Ete`4#Gb>V4baT>xMloEJtNUiX{I=}o
1330 zjXUSuUVpTz)$_*^Ol1&D9n0JPm~K8UwbbqL&$z9(Y<k!BIKtHC7o|cJ@qb-vFS-BH
1331 v)^`hcg)&V&QYxC>*^aCT=ropl44Wf98h1`<4=YxTc(v;NLYE!@<*i^c2jO2d
1333 literal 0
1334 HcmV?d00001
1336 diff --git a/tests/resources/crlf/.gitted/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb b/tests/resources/crlf/.gitted/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb
1337 new file mode 100644
1338 index 0000000000000000000000000000000000000000..8038a9b10bc3b9af4e1e4a198291456e74566343
1339 GIT binary patch
1340 literal 36
1341 scmb<m^geacKghr+A>qt<@26Ut=b!7I)bR3s>UCOQ_Yo^Y)g6w504Ajn00000
1343 literal 0
1344 HcmV?d00001
1346 diff --git a/tests/resources/crlf/.gitted/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41 b/tests/resources/crlf/.gitted/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41
1347 new file mode 100644
1348 index 0000000000000000000000000000000000000000..ec57bdeba5e506e741354d77acdcb22472929fb2
1349 GIT binary patch
1350 literal 36
1351 scmb<m^geacKghr+;lz3Gr&^llpX;8~@bZ27)a$gq?ju%)`ga^>0WSRzqyPW_
1353 literal 0
1354 HcmV?d00001
1356 diff --git a/tests/resources/crlf/.gitted/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e b/tests/resources/crlf/.gitted/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e
1357 new file mode 100644
1358 index 0000000000000000000000000000000000000000..ee4f4273d7f6cfab8beed2589e4091d2ac4eff28
1359 GIT binary patch
1360 literal 170
1361 zcmV;b09F5Z0iDj#jlwVtfMK39h2Kwia+4;lC4^vxPT<6jh@dS>!y&c@F#-d8zy7q&
1362 zb7^4RxNB7v$f6Q*2repn8G59V#Ak9o2g$J?9AolgZd`R~AnIf0E_fmml8}N#&McM(
1363 z9gyBmlfx{A@9n%+nErKvsnwD$b!}(Z>&)ePOxy3{9sCnLK-XJq5d)3zgB_wtpU0-(
1364 YX>$^RZJiZjS-3tSm#c2(1xk}l#h0#84FCWD
1366 literal 0
1367 HcmV?d00001
1369 diff --git a/tests/resources/crlf/.gitted/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f b/tests/resources/crlf/.gitted/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f
1370 new file mode 100644
1371 index 0000000000000000000000000000000000000000..e83fbc290c653dea7ac2037b899212e4c2f19705
1372 GIT binary patch
1373 literal 37
1374 tcmb<m^geacKghr+G2zU4@25|-G|#gONxH6dD2uAg6x0`Im}<cB82}#34jcdg
1376 literal 0
1377 HcmV?d00001
1379 diff --git a/tests/resources/crlf/.gitted/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d b/tests/resources/crlf/.gitted/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d
1380 new file mode 100644
1381 index 0000000000000000000000000000000000000000..f872be6e99d45ac3f960d5b99a0f0ed5d74ad4e6
1382 GIT binary patch
1383 literal 303
1384 zcmV+~0nq+<0V^p=O;s>4Fk>(@FfcPQQAo_m(M>MONn=>K=*2`E*?k&9zm7iJ@?go{
1385 zSl-AqBsD-4mD39@p8t{_ytH=vf;7?DVFI`Ete`5AGV>CPDs|z8wVJSpo`3qNN5iy2
1386 zvSPQ)o0rnI{Fq9CX0FdapSy6{H__{77iDgZj`2IcW$9*Ag}Ip(sVTZSX+T#pD42#G
1387 zP0uYo+i-1mz`l)Nwssty^BSjWh__aKXkK|b_}1aHx#t%==~Rs1O`3Ncss-8Pi*j|}
1388 zte4-G-Mn$<oZIV<R<(NmSc0hxVx(hv+aJ@-$EB9KJ^mTD^_ETV+8#%k+Wewah$8;4
1389 zOYJ51U)uU^;jU1osYgmh(>vRd6#@Oua*tti#7E=KDeYm!iV?3?y<h0k0|3GWt8b(d
1390 BpFjWr
1392 literal 0
1393 HcmV?d00001
1395 diff --git a/tests/resources/crlf/.gitted/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7 b/tests/resources/crlf/.gitted/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7
1396 new file mode 100644
1397 index 0000000000000000000000000000000000000000..38775d0050805307f9ad1e688eb1d4fb6c7b43a2
1398 GIT binary patch
1399 literal 37
1400 tcmb<m^geacKghr+CE?6@@26Ut=b!7I)bR3s`qb;RzV0Jdh9(=1^8h=j5MKZQ
1402 literal 0
1403 HcmV?d00001
1405 diff --git a/tests/resources/crlf/.gitted/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3 b/tests/resources/crlf/.gitted/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3
1406 new file mode 100644
1407 index 0000000000000000000000000000000000000000..0acc9744e1dbdaed5619a94adf6860a0983d8835
1408 GIT binary patch
1409 literal 36
1410 scmb<m^geacKghr+A>qt<@26Ut=bvkx)bR3s>UCOQ_Yo6A)mDz(043!Q%>V!Z
1412 literal 0
1413 HcmV?d00001
1415 diff --git a/tests/resources/crlf/.gitted/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4 b/tests/resources/crlf/.gitted/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4
1416 new file mode 100644
1417 index 0000000000000000000000000000000000000000..05d88fc8645aa8f991a418ec6ac102ca78bde4e5
1418 GIT binary patch
1419 literal 35
1420 rcmb<m^geacKgeK9%8B#dPqj49Ki55};pO|(>$JY^BUXk=Uyc(1B{~n8
1422 literal 0
1423 HcmV?d00001
1425 diff --git a/tests/resources/crlf/.gitted/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd b/tests/resources/crlf/.gitted/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd
1426 new file mode 100644
1427 index 0000000000000000000000000000000000000000..e288b975fede10d3b6e62a352cf103d4ea9c7b32
1428 GIT binary patch
1429 literal 179
1430 zcmV;k08IaQ0gaAZYQr!P0Q;>|?0<0C)mjfjDd`z<0%^4(qIO&q^>O^BAqObT?+hdR
1431 zwzUCv=BLqBfqaO_q>7f4<y_d2(^<(coV};ymx?K{`AA(a141m>1{8|(A2qlX$pyBQ
1432 zi)4o>lT|Nl(&squ9Zp|*fz#+s-uphz@S<C4>rt-L_bvEb^c85f7I}#r;edo_<o-DH
1433 h|Mu;L+`~3+rNGvHw1D(!t&{Y%LT#&F%`fkXOT==gUkd;L
1435 literal 0
1436 HcmV?d00001
1438 diff --git a/tests/resources/crlf/.gitted/refs/heads/master b/tests/resources/crlf/.gitted/refs/heads/master
1439 index c150a97763d3c0c3326d25ce6c2b1a53773e18e0..50a386e51c0da6f47615efc5fda44ca3849ac9dc 100644
1440 GIT binary patch
1441 literal 41
1442 ucmV~$$pHW$2m`Rc(|7=daf-tJBbZod04B^L7iFHxR*$!finvB^2Woum><dZ&
1444 literal 42
1445 wcmV~$$qfJ?2n4{tiM>E%QOe=$zXWGUB(jhegN`b2gT>8{3NG;*($VI<J_AAvHUIzs
1448 1.9.5.msysgit.1