Drop unused variables
[TortoiseGit.git] / ext / libgit2-0006-Make-checking-out-files-behave-like-vanilla-git-conc.patch
blob7bdd330d8f8fbf84a4fb2f23eda2718312573f37
1 From 1a8f70c4073906938f02c373c4d366fc7cb8f651 Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Sun, 25 Jan 2015 20:17:38 +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 * "* text eol=crlf" on LF-only platforms
11 Signed-off-by: Sven Strickroth <email@cs-ware.de>
12 ---
13 CHANGELOG.md | 6 +
14 src/buf_text.c | 14 +-
15 src/crlf.c | 34 ++-
16 tests/checkout/crlf.c | 240 +++++++++++++++++++++
17 tests/core/buffer.c | 24 ++-
18 tests/filter/crlf.h | 6 +
19 .../16/78031ee023a23bd3515e4e1693b661a69f0a73 | Bin 0 -> 193 bytes
20 .../20/3555c5676d75cd80d69b50beb1f4b588c59ceb | Bin 0 -> 36 bytes
21 .../41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41 | Bin 0 -> 36 bytes
22 .../69/597764abeaa1a403ebf589d2ea579c6a8f877e | Bin 0 -> 170 bytes
23 .../85/340755cfe5e28c2835781978bb1cece91b3d0f | Bin 0 -> 37 bytes
24 .../92/0e90a663bea5d740989d5f935f6dfb473a0c5d | Bin 0 -> 303 bytes
25 .../aa/f083a9cb53dac3669dcfa0e48921580d629ec7 | Bin 0 -> 37 bytes
26 .../af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3 | Bin 0 -> 36 bytes
27 .../d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4 | Bin 0 -> 35 bytes
28 .../de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd | Bin 0 -> 179 bytes
29 tests/resources/crlf/.gitted/refs/heads/master | Bin 42 -> 41 bytes
30 17 files changed, 305 insertions(+), 19 deletions(-)
31 create mode 100644 tests/resources/crlf/.gitted/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73
32 create mode 100644 tests/resources/crlf/.gitted/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb
33 create mode 100644 tests/resources/crlf/.gitted/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41
34 create mode 100644 tests/resources/crlf/.gitted/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e
35 create mode 100644 tests/resources/crlf/.gitted/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f
36 create mode 100644 tests/resources/crlf/.gitted/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d
37 create mode 100644 tests/resources/crlf/.gitted/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7
38 create mode 100644 tests/resources/crlf/.gitted/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3
39 create mode 100644 tests/resources/crlf/.gitted/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4
40 create mode 100644 tests/resources/crlf/.gitted/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd
42 diff --git a/CHANGELOG.md b/CHANGELOG.md
43 index a2e9386..443925f 100644
44 --- a/CHANGELOG.md
45 +++ b/CHANGELOG.md
46 @@ -16,6 +16,12 @@ v0.22 + 1
47 * especially files containing single CR chars are added as is now
48 * honor "text" attribute for forcing a file being interpreted as text
50 +* LF -> CRLF filter now handles files on checkout the way vanilla git does
51 + * honor "text" attribute forcing the processing of binary files and eol=crlf processing on LF platforms
52 + * skip files containing the same number of LF and CRLF eols
53 + * fix binary detection (only apply it for AUTO and GUESS files)
54 + * correctly handle files with mixed line endings (Cr, Lf and also CrLf at the same time and in different combinations)
56 * Rename and copy detection is enabled for small files.
58 ### API additions
59 diff --git a/src/buf_text.c b/src/buf_text.c
60 index cb3661e..3eefdb6 100644
61 --- a/src/buf_text.c
62 +++ b/src/buf_text.c
63 @@ -125,16 +125,16 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src)
64 size_t copylen = next - scan;
65 size_t needsize = tgt->size + copylen + 2 + 1;
67 - /* if we find mixed line endings, bail */
68 - if (next > start && next[-1] == '\r') {
69 - git_buf_free(tgt);
70 - return GIT_PASSTHROUGH;
71 - }
73 if (tgt->asize < needsize && git_buf_grow(tgt, needsize) < 0)
74 return -1;
76 - if (next > scan) {
77 + /* if we find mixed line endings, ignore it as vanilla git does
78 + * the decision if this function needs to be called at all is made in the crlf filter
79 + */
80 + if (next > start && next[-1] == '\r') {
81 + memcpy(tgt->ptr + tgt->size, scan, copylen - 1);
82 + tgt->size += copylen - 1;
83 + } else if (next > scan) {
84 memcpy(tgt->ptr + tgt->size, scan, copylen);
85 tgt->size += copylen;
87 diff --git a/src/crlf.c b/src/crlf.c
88 index 2516c40..a669e78 100644
89 --- a/src/crlf.c
90 +++ b/src/crlf.c
91 @@ -242,15 +242,13 @@ static int crlf_apply_to_workdir(
92 struct crlf_attrs *ca, git_buf *to, const git_buf *from)
94 const char *workdir_ending = NULL;
95 + git_buf_text_stats stats;
96 + int isBinary;
98 /* Empty file? Nothing to do. */
99 if (git_buf_len(from) == 0)
100 return 0;
102 - /* Don't filter binary files */
103 - if (git_buf_text_is_binary(from))
104 - return GIT_PASSTHROUGH;
106 /* Determine proper line ending */
107 workdir_ending = line_ending(ca);
108 if (!workdir_ending)
109 @@ -260,6 +258,34 @@ static int crlf_apply_to_workdir(
110 if (strcmp(workdir_ending, "\r\n") != 0)
111 return GIT_PASSTHROUGH;
113 + isBinary = git_buf_text_gather_stats(&stats, from, false);
115 + /* Nothing to convert */
116 + if (!stats.lf)
117 + return GIT_PASSTHROUGH;
119 + /* Is file already CRLF? */
120 + if (stats.lf == stats.crlf)
121 + return GIT_PASSTHROUGH;
123 + if (ca->crlf_action == GIT_CRLF_AUTO || ca->crlf_action == GIT_CRLF_GUESS) {
125 + if (ca->crlf_action == GIT_CRLF_GUESS) {
126 + /*
127 + * If the file in the index has any CR OR crlf in it, do not convert.
128 + */
129 + if (stats.cr || stats.crlf)
130 + return GIT_PASSTHROUGH;
133 + /* If we have any bare CR characters, we're not going to touch it */
134 + if (stats.cr != stats.crlf)
135 + return GIT_PASSTHROUGH;
137 + if (isBinary)
138 + return GIT_PASSTHROUGH;
141 return git_buf_text_lf_to_crlf(to, from);
144 diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
145 index b6d4e94..c7aa1dd 100644
146 --- a/tests/checkout/crlf.c
147 +++ b/tests/checkout/crlf.c
148 @@ -29,6 +29,13 @@ void test_checkout_crlf__detect_crlf_autocrlf_false(void)
150 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
151 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
152 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
153 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
155 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
156 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
157 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
158 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
161 void test_checkout_crlf__autocrlf_false_index_size_is_unfiltered_size(void)
162 @@ -50,6 +57,12 @@ void test_checkout_crlf__autocrlf_false_index_size_is_unfiltered_size(void)
163 cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL);
164 cl_assert(entry->file_size == strlen(ALL_CRLF_TEXT_RAW));
166 + cl_assert((entry = git_index_get_bypath(index, "mixed-lf-cr", 0)) != NULL);
167 + cl_assert(entry->file_size == strlen(MIXED_LF_CR_RAW));
169 + cl_assert((entry = git_index_get_bypath(index, "mixed-lf-cr-crlf", 0)) != NULL);
170 + cl_assert(entry->file_size == strlen(MIXED_LF_CR_CRLF_RAW));
172 git_index_free(index);
175 @@ -68,6 +81,11 @@ void test_checkout_crlf__detect_crlf_autocrlf_true(void)
176 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
178 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
180 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
181 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
182 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
183 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
186 void test_checkout_crlf__more_lf_autocrlf_true(void)
187 @@ -278,6 +296,12 @@ void test_checkout_crlf__autocrlf_true_no_attrs(void)
188 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
189 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
192 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
193 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
195 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
196 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
199 void test_checkout_crlf__autocrlf_input_no_attrs(void)
200 @@ -291,6 +315,17 @@ void test_checkout_crlf__autocrlf_input_no_attrs(void)
202 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
203 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
205 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
206 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
208 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
209 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
211 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
212 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
213 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
214 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
217 void test_checkout_crlf__autocrlf_false_text_auto_attr(void)
218 @@ -307,12 +342,194 @@ void test_checkout_crlf__autocrlf_false_text_auto_attr(void)
219 if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
220 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
221 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
222 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
223 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
224 } else {
225 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
226 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
227 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
228 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
231 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
232 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
233 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
234 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
237 +void test_checkout_crlf__autocrlf_false_text_crlf_attr(void)
239 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
240 + opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
242 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=crlf\n");
244 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
246 + git_checkout_head(g_repo, &opts);
248 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
249 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
251 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
252 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
254 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
255 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
257 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
258 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
259 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
260 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
263 +void test_checkout_crlf__autocrlf_false_text_crlf_attr2(void)
265 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
266 + opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
268 + cl_git_mkfile("./crlf/.gitattributes", "* text eol=lf\n");
270 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
272 + git_checkout_head(g_repo, &opts);
274 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
275 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
277 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
278 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
280 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
281 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
283 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_LF);
284 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_LF);
285 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_LF);
286 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_LF);
289 +void test_checkout_crlf__autocrlf_false_text_crlf_attr3(void)
291 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
292 + opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
294 + cl_git_mkfile("./crlf/.gitattributes", "* crlf\n");
296 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
298 + git_checkout_head(g_repo, &opts);
300 + if (GIT_EOL_NATIVE == GIT_EOL_LF)
301 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
302 + else
303 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
304 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
306 + if (GIT_EOL_NATIVE == GIT_EOL_LF) {
307 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
308 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
309 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
310 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
311 + } else {
312 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
313 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
314 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
315 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
318 + if (GIT_EOL_NATIVE == GIT_EOL_LF)
319 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
320 + else
321 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
322 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
323 + if (GIT_EOL_NATIVE == GIT_EOL_LF) {
324 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
325 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
326 + } else {
327 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
328 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
332 +void test_checkout_crlf__autocrlf_false_text_crlf_attr4(void)
334 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
335 + opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
337 + cl_git_mkfile("./crlf/.gitattributes", "* -crlf\n");
339 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
341 + git_checkout_head(g_repo, &opts);
343 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
344 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
346 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
347 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
349 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
350 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
352 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_LF);
353 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_LF);
354 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_LF);
355 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_LF);
358 +void test_checkout_crlf__autocrlf_false_text_crlf_attr5(void)
360 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
361 + opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
363 + cl_git_mkfile("./crlf/.gitattributes", "* eol=crlf\n");
365 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
367 + git_checkout_head(g_repo, &opts);
369 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
370 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
372 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
373 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
375 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_AS_CRLF);
376 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_AS_CRLF);
378 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_CRLF);
379 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_CRLF);
380 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_CRLF);
381 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_CRLF);
384 +void test_checkout_crlf__autocrlf_false_text_crlf_attr6(void)
386 + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
387 + opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
389 + cl_git_mkfile("./crlf/.gitattributes", "* eol=lf\n");
391 + cl_repo_set_bool(g_repo, "core.autocrlf", false);
393 + git_checkout_head(g_repo, &opts);
395 + check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
396 + check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
398 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
399 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
401 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
402 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
404 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_AS_LF);
405 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_AS_LF);
406 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_AS_LF);
407 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_AS_LF);
410 void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
412 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
413 @@ -327,10 +544,22 @@ void test_checkout_crlf__autocrlf_true_text_auto_attr(void)
414 if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
415 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
416 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
417 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_AS_CRLF);
418 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_AS_CRLF);
419 } else {
420 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
421 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
422 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
423 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
426 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
427 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
429 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
430 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
431 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
432 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
435 void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
436 @@ -346,4 +575,15 @@ void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
438 check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
439 check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
441 + check_file_contents("./crlf/more-lf", MORE_LF_TEXT_RAW);
442 + check_file_contents("./crlf/more-crlf", MORE_CRLF_TEXT_RAW);
444 + check_file_contents("./crlf/mixed-lf-cr", MIXED_LF_CR_RAW);
445 + check_file_contents("./crlf/mixed-lf-cr-crlf", MIXED_LF_CR_CRLF_RAW);
447 + check_file_contents("./crlf/binary-all-lf", BINARY_ALL_LF_TEXT_RAW);
448 + check_file_contents("./crlf/binary-all-crlf", BINARY_ALL_CRLF_TEXT_RAW);
449 + check_file_contents("./crlf/binary-mixed-lf-cr", BINARY_MIXED_LF_CR_RAW);
450 + check_file_contents("./crlf/binary-mixed-lf-cr-crlf", BINARY_MIXED_LF_CR_CRLF_RAW);
452 diff --git a/tests/core/buffer.c b/tests/core/buffer.c
453 index d28aa21..67ab560 100644
454 --- a/tests/core/buffer.c
455 +++ b/tests/core/buffer.c
456 @@ -1054,14 +1054,16 @@ void test_core_buffer__lf_and_crlf_conversions(void)
458 git_buf_sets(&src, "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n");
460 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
461 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
462 + check_buf("crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n", tgt);
464 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
465 check_buf("crlf\ncrlf\ncrlf\ncrlf\n", tgt);
467 git_buf_sets(&src, "\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf");
469 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
470 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
471 + check_buf("\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf\r\ncrlf", tgt);
473 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
474 check_buf("\ncrlf\ncrlf\ncrlf\ncrlf\ncrlf", tgt);
475 @@ -1070,7 +1072,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
477 git_buf_sets(&src, "\nlf\nlf\ncrlf\r\nlf\nlf\ncrlf\r\n");
479 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
480 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
481 + check_buf("\r\nlf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\ncrlf\r\n", tgt);
482 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
483 check_buf("\nlf\nlf\ncrlf\nlf\nlf\ncrlf\n", tgt);
485 @@ -1078,7 +1081,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
487 git_buf_sets(&src, "\ncrlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf");
489 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
490 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
491 + check_buf("\r\ncrlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf", tgt);
492 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
493 check_buf("\ncrlf\ncrlf\nlf\ncrlf\ncrlf", tgt);
495 @@ -1086,7 +1090,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
497 git_buf_sets(&src, "\rcrlf\r\nlf\nlf\ncr\rcrlf\r\nlf\ncr\r");
499 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
500 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
501 + check_buf("\rcrlf\r\nlf\r\nlf\r\ncr\rcrlf\r\nlf\r\ncr\r", tgt);
502 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
503 check_buf("\rcrlf\nlf\nlf\ncr\rcrlf\nlf\ncr\r", tgt);
505 @@ -1102,7 +1107,8 @@ void test_core_buffer__lf_and_crlf_conversions(void)
506 /* blob correspondence tests */
508 git_buf_sets(&src, ALL_CRLF_TEXT_RAW);
509 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
510 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
511 + check_buf(ALL_CRLF_TEXT_RAW, tgt);
512 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
513 check_buf(ALL_CRLF_TEXT_AS_LF, tgt);
514 git_buf_free(&src);
515 @@ -1117,14 +1123,16 @@ void test_core_buffer__lf_and_crlf_conversions(void)
516 git_buf_free(&tgt);
518 git_buf_sets(&src, MORE_CRLF_TEXT_RAW);
519 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
520 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
521 + check_buf(MORE_CRLF_TEXT_AS_CRLF, tgt);
522 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
523 check_buf(MORE_CRLF_TEXT_AS_LF, tgt);
524 git_buf_free(&src);
525 git_buf_free(&tgt);
527 git_buf_sets(&src, MORE_LF_TEXT_RAW);
528 - cl_git_fail_with(GIT_PASSTHROUGH, git_buf_text_lf_to_crlf(&tgt, &src));
529 + cl_git_pass(git_buf_text_lf_to_crlf(&tgt, &src));
530 + check_buf(MORE_LF_TEXT_AS_CRLF, tgt);
531 cl_git_pass(git_buf_text_crlf_to_lf(&tgt, &src));
532 check_buf(MORE_LF_TEXT_AS_LF, tgt);
533 git_buf_free(&src);
534 diff --git a/tests/filter/crlf.h b/tests/filter/crlf.h
535 index 0a7a10d..bb13162 100644
536 --- a/tests/filter/crlf.h
537 +++ b/tests/filter/crlf.h
538 @@ -11,6 +11,8 @@
539 #define ALL_LF_TEXT_RAW "lf\nlf\nlf\nlf\nlf\n"
540 #define MORE_CRLF_TEXT_RAW "crlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf\r\n"
541 #define MORE_LF_TEXT_RAW "lf\nlf\ncrlf\r\nlf\nlf\n"
542 +#define MIXED_LF_CR_RAW "one\ntwo\rthree\nfour\r"
543 +#define MIXED_LF_CR_CRLF_RAW "one\ntwo\rthree\r\nfour\r"
544 #define BINARY_ALL_CRLF_TEXT_RAW "\01one\r\ntwo\r\nthree\r\nfour\r\n"
545 #define BINARY_ALL_LF_TEXT_RAW "\01one\ntwo\nthree\nfour\n"
546 #define BINARY_MIXED_LF_CR_RAW "\01" MIXED_LF_CR_RAW
547 @@ -20,6 +22,8 @@
548 #define ALL_LF_TEXT_AS_CRLF "lf\r\nlf\r\nlf\r\nlf\r\nlf\r\n"
549 #define MORE_CRLF_TEXT_AS_CRLF "crlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf\r\n"
550 #define MORE_LF_TEXT_AS_CRLF "lf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\n"
551 +#define MIXED_LF_CR_AS_CRLF "one\r\ntwo\rthree\r\nfour\r"
552 +#define MIXED_LF_CR_CRLF_AS_CRLF MIXED_LF_CR_AS_CRLF
553 #define BINARY_ALL_CRLF_TEXT_AS_CRLF BINARY_ALL_CRLF_TEXT_RAW
554 #define BINARY_ALL_LF_TEXT_AS_CRLF BINARY_ALL_CRLF_TEXT_AS_CRLF
555 #define BINARY_MIXED_LF_CR_AS_CRLF "\01" MIXED_LF_CR_AS_CRLF
556 @@ -29,6 +33,8 @@
557 #define ALL_LF_TEXT_AS_LF ALL_LF_TEXT_RAW
558 #define MORE_CRLF_TEXT_AS_LF "crlf\ncrlf\nlf\ncrlf\ncrlf\n"
559 #define MORE_LF_TEXT_AS_LF "lf\nlf\ncrlf\nlf\nlf\n"
560 +#define MIXED_LF_CR_AS_LF MIXED_LF_CR_RAW
561 +#define MIXED_LF_CR_CRLF_AS_LF MIXED_LF_CR_CRLF_RAW
562 #define BINARY_ALL_CRLF_TEXT_AS_LF BINARY_ALL_CRLF_TEXT_RAW
563 #define BINARY_ALL_LF_TEXT_AS_LF BINARY_ALL_LF_TEXT_RAW
564 #define BINARY_MIXED_LF_CR_AS_LF BINARY_MIXED_LF_CR_RAW
565 diff --git a/tests/resources/crlf/.gitted/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73 b/tests/resources/crlf/.gitted/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73
566 new file mode 100644
567 index 0000000000000000000000000000000000000000..4aa4ffb1d6714929c6a392d9e09de3644ba8cdc6
568 GIT binary patch
569 literal 193
570 zcmV;y06zbC0V^p=O;s>5GG#C{FfcPQQAo_m(M>MONn=>K=*2`E*?k&9zm7iJ@?go{
571 zSl-AqBsD-4mD39@p8t{_ytH=vf;7?DVFI`Ete`4#Gb>V4baT>xMloEJtNUiX{I=}o
572 zjXUSuUVpTz)$_*^Ol1&D9n0JPm~K8UwbbqL&$z9(Y<k!BIKtHC7o|cJ@qb-vFS-BH
573 v)^`hcg)&V&QYxC>*^aCT=ropl44Wf98h1`<4=YxTc(v;NLYE!@<*i^c2jO2d
575 literal 0
576 HcmV?d00001
578 diff --git a/tests/resources/crlf/.gitted/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb b/tests/resources/crlf/.gitted/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb
579 new file mode 100644
580 index 0000000000000000000000000000000000000000..8038a9b10bc3b9af4e1e4a198291456e74566343
581 GIT binary patch
582 literal 36
583 scmb<m^geacKghr+A>qt<@26Ut=b!7I)bR3s>UCOQ_Yo^Y)g6w504Ajn00000
585 literal 0
586 HcmV?d00001
588 diff --git a/tests/resources/crlf/.gitted/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41 b/tests/resources/crlf/.gitted/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41
589 new file mode 100644
590 index 0000000000000000000000000000000000000000..ec57bdeba5e506e741354d77acdcb22472929fb2
591 GIT binary patch
592 literal 36
593 scmb<m^geacKghr+;lz3Gr&^llpX;8~@bZ27)a$gq?ju%)`ga^>0WSRzqyPW_
595 literal 0
596 HcmV?d00001
598 diff --git a/tests/resources/crlf/.gitted/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e b/tests/resources/crlf/.gitted/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e
599 new file mode 100644
600 index 0000000000000000000000000000000000000000..ee4f4273d7f6cfab8beed2589e4091d2ac4eff28
601 GIT binary patch
602 literal 170
603 zcmV;b09F5Z0iDj#jlwVtfMK39h2Kwia+4;lC4^vxPT<6jh@dS>!y&c@F#-d8zy7q&
604 zb7^4RxNB7v$f6Q*2repn8G59V#Ak9o2g$J?9AolgZd`R~AnIf0E_fmml8}N#&McM(
605 z9gyBmlfx{A@9n%+nErKvsnwD$b!}(Z>&)ePOxy3{9sCnLK-XJq5d)3zgB_wtpU0-(
606 YX>$^RZJiZjS-3tSm#c2(1xk}l#h0#84FCWD
608 literal 0
609 HcmV?d00001
611 diff --git a/tests/resources/crlf/.gitted/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f b/tests/resources/crlf/.gitted/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f
612 new file mode 100644
613 index 0000000000000000000000000000000000000000..e83fbc290c653dea7ac2037b899212e4c2f19705
614 GIT binary patch
615 literal 37
616 tcmb<m^geacKghr+G2zU4@25|-G|#gONxH6dD2uAg6x0`Im}<cB82}#34jcdg
618 literal 0
619 HcmV?d00001
621 diff --git a/tests/resources/crlf/.gitted/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d b/tests/resources/crlf/.gitted/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d
622 new file mode 100644
623 index 0000000000000000000000000000000000000000..f872be6e99d45ac3f960d5b99a0f0ed5d74ad4e6
624 GIT binary patch
625 literal 303
626 zcmV+~0nq+<0V^p=O;s>4Fk>(@FfcPQQAo_m(M>MONn=>K=*2`E*?k&9zm7iJ@?go{
627 zSl-AqBsD-4mD39@p8t{_ytH=vf;7?DVFI`Ete`5AGV>CPDs|z8wVJSpo`3qNN5iy2
628 zvSPQ)o0rnI{Fq9CX0FdapSy6{H__{77iDgZj`2IcW$9*Ag}Ip(sVTZSX+T#pD42#G
629 zP0uYo+i-1mz`l)Nwssty^BSjWh__aKXkK|b_}1aHx#t%==~Rs1O`3Ncss-8Pi*j|}
630 zte4-G-Mn$<oZIV<R<(NmSc0hxVx(hv+aJ@-$EB9KJ^mTD^_ETV+8#%k+Wewah$8;4
631 zOYJ51U)uU^;jU1osYgmh(>vRd6#@Oua*tti#7E=KDeYm!iV?3?y<h0k0|3GWt8b(d
632 BpFjWr
634 literal 0
635 HcmV?d00001
637 diff --git a/tests/resources/crlf/.gitted/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7 b/tests/resources/crlf/.gitted/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7
638 new file mode 100644
639 index 0000000000000000000000000000000000000000..38775d0050805307f9ad1e688eb1d4fb6c7b43a2
640 GIT binary patch
641 literal 37
642 tcmb<m^geacKghr+CE?6@@26Ut=b!7I)bR3s`qb;RzV0Jdh9(=1^8h=j5MKZQ
644 literal 0
645 HcmV?d00001
647 diff --git a/tests/resources/crlf/.gitted/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3 b/tests/resources/crlf/.gitted/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3
648 new file mode 100644
649 index 0000000000000000000000000000000000000000..0acc9744e1dbdaed5619a94adf6860a0983d8835
650 GIT binary patch
651 literal 36
652 scmb<m^geacKghr+A>qt<@26Ut=bvkx)bR3s>UCOQ_Yo6A)mDz(043!Q%>V!Z
654 literal 0
655 HcmV?d00001
657 diff --git a/tests/resources/crlf/.gitted/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4 b/tests/resources/crlf/.gitted/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4
658 new file mode 100644
659 index 0000000000000000000000000000000000000000..05d88fc8645aa8f991a418ec6ac102ca78bde4e5
660 GIT binary patch
661 literal 35
662 rcmb<m^geacKgeK9%8B#dPqj49Ki55};pO|(>$JY^BUXk=Uyc(1B{~n8
664 literal 0
665 HcmV?d00001
667 diff --git a/tests/resources/crlf/.gitted/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd b/tests/resources/crlf/.gitted/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd
668 new file mode 100644
669 index 0000000000000000000000000000000000000000..e288b975fede10d3b6e62a352cf103d4ea9c7b32
670 GIT binary patch
671 literal 179
672 zcmV;k08IaQ0gaAZYQr!P0Q;>|?0<0C)mjfjDd`z<0%^4(qIO&q^>O^BAqObT?+hdR
673 zwzUCv=BLqBfqaO_q>7f4<y_d2(^<(coV};ymx?K{`AA(a141m>1{8|(A2qlX$pyBQ
674 zi)4o>lT|Nl(&squ9Zp|*fz#+s-uphz@S<C4>rt-L_bvEb^c85f7I}#r;edo_<o-DH
675 h|Mu;L+`~3+rNGvHw1D(!t&{Y%LT#&F%`fkXOT==gUkd;L
677 literal 0
678 HcmV?d00001
680 diff --git a/tests/resources/crlf/.gitted/refs/heads/master b/tests/resources/crlf/.gitted/refs/heads/master
681 index c150a97763d3c0c3326d25ce6c2b1a53773e18e0..50a386e51c0da6f47615efc5fda44ca3849ac9dc 100644
682 GIT binary patch
683 literal 41
684 ucmV~$$pHW$2m`Rc(|7=daf-tJBbZod04B^L7iFHxR*$!finvB^2Woum><dZ&
686 literal 42
687 wcmV~$$qfJ?2n4{tiM>E%QOe=$zXWGUB(jhegN`b2gT>8{3NG;*($VI<J_AAvHUIzs
690 1.9.5.msysgit.0