From 0d65acade84a5ff2421cd52de82a8963f004d481 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 11 Jan 2013 11:24:26 -0800 Subject: 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. --- src/diff_output.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/diff_output.c') diff --git a/src/diff_output.c b/src/diff_output.c index f98665dfb..dcff78871 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -142,7 +142,12 @@ static int diff_delta_is_binary_by_content( GIT_UNUSED(ctxt); if ((file->flags & KNOWN_BINARY_FLAGS) == 0) { - if (git_buf_text_is_binary(&search)) + /* TODO: provide encoding / binary detection callbacks that can + * be UTF-8 aware, etc. For now, instead of trying to be smart, + * let's just use the simple NUL-byte detection that core git uses. + */ + /* previously was: if (git_buf_text_is_binary(&search)) */ + if (git_buf_text_contains_nul(&search)) file->flags |= GIT_DIFF_FILE_BINARY; else file->flags |= GIT_DIFF_FILE_NOT_BINARY; -- cgit v1.2.1