diff options
author | Edward Thomson <ethomson@microsoft.com> | 2014-05-30 11:30:53 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2014-05-30 11:30:53 -0500 |
commit | 49837fd49fb9de999be5add82a12bf6332d4703f (patch) | |
tree | 027d837aaa0b84a864af1d663d152a01c1747e94 /tests | |
parent | 58eea5ebf40b698cbaf028b23ee6157d5eb6582c (diff) | |
download | libgit2-49837fd49fb9de999be5add82a12bf6332d4703f.tar.gz |
Ignore core.safecrlf=warn until we have a warn infrastructure
Diffstat (limited to 'tests')
-rw-r--r-- | tests/filter/crlf.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c index 334b1e349..a31dac965 100644 --- a/tests/filter/crlf.c +++ b/tests/filter/crlf.c @@ -196,3 +196,44 @@ void test_filter_crlf__no_safecrlf(void) git_buf_free(&out); } +void test_filter_crlf__safecrlf_warn(void) +{ + git_filter_list *fl; + git_filter *crlf; + git_buf in = {0}, out = GIT_BUF_INIT; + + cl_repo_set_string(g_repo, "core.safecrlf", "warn"); + + cl_git_pass(git_filter_list_new( + &fl, g_repo, GIT_FILTER_TO_ODB, 0)); + + crlf = git_filter_lookup(GIT_FILTER_CRLF); + cl_assert(crlf != NULL); + + cl_git_pass(git_filter_list_push(fl, crlf, NULL)); + + /* Normalized \r\n succeeds with safecrlf=warn */ + in.ptr = "Normal\r\nCRLF\r\nline-endings.\r\n"; + in.size = strlen(in.ptr); + + cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in)); + cl_assert_equal_s("Normal\nCRLF\nline-endings.\n", out.ptr); + + /* Mix of line endings succeeds with safecrlf=warn */ + in.ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n"; + in.size = strlen(in.ptr); + + cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in)); + /* TODO: check for warning */ + cl_assert_equal_s("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n", out.ptr); + + /* Normalized \n is reversible, so does not fail with safecrlf=warn */ + in.ptr = "Normal\nLF\nonly\nline-endings.\n"; + in.size = strlen(in.ptr); + + cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in)); + cl_assert_equal_s(in.ptr, out.ptr); + + git_filter_list_free(fl); + git_buf_free(&out); +} |