Migrate some tests
[TortoiseGit.git] / ext / libgit2-0003-Adding-a-CRLF-file-with-AutoCrLf-input-and-SafeCrLf-.patch
blob30cab3a85e017639d613be52302d7d1d86b390b4
1 From f7ae42e37cb673ab042b04197ab7c197c299fd5c Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Fri, 23 Jan 2015 15:34:14 +0100
4 Subject: [PATCH 3/6] Adding a CRLF-file with AutoCrLf=input and SafeCrLf=true
5 does not fail as with vanilla git
7 Signed-off-by: Sven Strickroth <email@cs-ware.de>
8 ---
9 CHANGELOG.md | 1 +
10 src/crlf.c | 13 +++++++++++++
11 tests/index/crlf.c | 6 ++++++
12 3 files changed, 20 insertions(+)
14 diff --git a/CHANGELOG.md b/CHANGELOG.md
15 index 1894d07..17da574 100644
16 --- a/CHANGELOG.md
17 +++ b/CHANGELOG.md
18 @@ -8,6 +8,7 @@ v0.22 + 1
20 * LF -> CRLF filter now correctly honors SafeCrLf=true errors
21 * LF only files were accepted with AutoCrLf=true on CRLF platforms
22 + * files containig CRLF in combination with AutoCrLf=input were accepted
24 * Rename and copy detection is enabled for small files.
26 diff --git a/src/crlf.c b/src/crlf.c
27 index bb1657b..29fa9a0 100644
28 --- a/src/crlf.c
29 +++ b/src/crlf.c
30 @@ -156,6 +156,19 @@ static int crlf_apply_to_odb(
31 default:
32 break;
34 + } else if (stats.crlf && ca->auto_crlf == GIT_AUTO_CRLF_INPUT) {
35 + switch (ca->safe_crlf) {
36 + case GIT_SAFE_CRLF_FAIL:
37 + giterr_set(
38 + GITERR_FILTER, "CRLF would be replaced by LF in '%s'",
39 + git_filter_source_path(src));
40 + return -1;
41 + case GIT_SAFE_CRLF_WARN:
42 + /* TODO: issue warning when warning API is available */;
43 + break;
44 + default:
45 + break;
46 + }
50 diff --git a/tests/index/crlf.c b/tests/index/crlf.c
51 index 803c141..38e7916 100644
52 --- a/tests/index/crlf.c
53 +++ b/tests/index/crlf.c
54 @@ -152,6 +152,9 @@ void test_index_crlf__safecrlf_true_autocrlf_input_text_auto_attr(void)
56 cl_git_pass(git_oid_fromstr(&oid, FILE_OID_LF));
57 cl_assert_equal_oid(&oid, &entry->id);
59 + cl_git_mkfile("./crlf/newfile2.txt", FILE_CONTENTS_CRLF);
60 + cl_git_fail(git_index_add_bypath(g_index, "newfile2.txt"));
63 void test_index_crlf__safecrlf_true_autocrlf_input_text__no_attr(void)
64 @@ -169,6 +172,9 @@ void test_index_crlf__safecrlf_true_autocrlf_input_text__no_attr(void)
66 cl_git_pass(git_oid_fromstr(&oid, FILE_OID_LF));
67 cl_assert_equal_oid(&oid, &entry->id);
69 + cl_git_mkfile("./crlf/newfile2.txt", FILE_CONTENTS_CRLF);
70 + cl_git_fail(git_index_add_bypath(g_index, "newfile2.txt"));
73 void test_index_crlf__safecrlf_true_no_attrs(void)
74 --
75 1.9.5.msysgit.0