diff options
author | Russell Belfer <rb@github.com> | 2013-01-11 23:24:26 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-11 23:24:26 +0400 |
commit | 0d65acade84a5ff2421cd52de82a8963f004d481 (patch) | |
tree | 5c1f0ba04710e32642e32a4cadf7a8e14dc0aba6 /tests-clar/core | |
parent | d0b14cea0e1ff09af83a801c1a9cf1a431d46d0c (diff) |
Match binary file check of core git in diff
Core git just looks for NUL bytes in files when deciding about
is-binary inside diff (although it uses a better algorithm in
checkout, when deciding if CRLF conversion should be done).
Libgit2 was using the better algorithm in both places, but that
is causing some confusion. For now, this makes diff just look
for NUL bytes to decide if a file is binary by content in diff.
Diffstat (limited to 'tests-clar/core')
-rw-r--r-- | tests-clar/core/buffer.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests-clar/core/buffer.c b/tests-clar/core/buffer.c index 40fc4c571..5d9b7850c 100644 --- a/tests-clar/core/buffer.c +++ b/tests-clar/core/buffer.c @@ -704,3 +704,26 @@ void test_core_buffer__base64(void) git_buf_free(&buf); } + +void test_core_buffer__classify_with_utf8(void) +{ + char *data0 = "Simple text\n"; + size_t data0len = 12; + char *data1 = "Is that UTF-8 data I seeā¦\nYep!\n"; + size_t data1len = 31; + char *data2 = "Internal NUL!!!\000\n\nI see you!\n"; + size_t data2len = 29; + git_buf b; + + b.ptr = data0; b.size = b.asize = data0len; + cl_assert(!git_buf_text_is_binary(&b)); + cl_assert(!git_buf_text_contains_nul(&b)); + + b.ptr = data1; b.size = b.asize = data1len; + cl_assert(git_buf_text_is_binary(&b)); + cl_assert(!git_buf_text_contains_nul(&b)); + + b.ptr = data2; b.size = b.asize = data2len; + cl_assert(git_buf_text_is_binary(&b)); + cl_assert(git_buf_text_contains_nul(&b)); +} |