Allow to disable update checks on update dialog
[TortoiseGit.git] / ext / libgit2-0001-Make-binary-detection-work-similar-to-vanilla-git.patch
bloba96bd603e75f4407765ae27bf0284467709f43c1
1 From 49424f9357a6428c72f660a11fe8e68c45f512b1 Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Thu, 13 Nov 2014 19:30:47 +0100
4 Subject: [PATCH] Make binary detection work similar to vanilla git
6 Main change: Don't treat chars > 128 as non-printable (common in UTF-8 files)
8 Signed-off-by: Sven Strickroth <email@cs-ware.de>
9 ---
10 src/buf_text.c | 2 +-
11 tests/core/buffer.c | 2 +-
12 2 files changed, 2 insertions(+), 2 deletions(-)
14 diff --git a/src/buf_text.c b/src/buf_text.c
15 index 8d2b141..99abefa 100644
16 --- a/src/buf_text.c
17 +++ b/src/buf_text.c
18 @@ -190,7 +190,7 @@ bool git_buf_text_is_binary(const git_buf *buf)
19 while (scan < end) {
20 unsigned char c = *scan++;
22 - if (c > 0x1F && c < 0x7F)
23 + if ((c > 0x1F && c != 127) || c == '\b' || c == '\033' || c == '\014') /* handle BS, ESC and FF and all (chars > 0x1F excluding DEL) as printable */
24 printable++;
25 else if (c == '\0')
26 return true;
27 diff --git a/tests/core/buffer.c b/tests/core/buffer.c
28 index 641fed6..4549d9f 100644
29 --- a/tests/core/buffer.c
30 +++ b/tests/core/buffer.c
31 @@ -831,7 +831,7 @@ void test_core_buffer__classify_with_utf8(void)
32 cl_assert(!git_buf_text_contains_nul(&b));
34 b.ptr = data1; b.size = b.asize = data1len;
35 - cl_assert(git_buf_text_is_binary(&b));
36 + cl_assert(!git_buf_text_is_binary(&b)); // UTF-8 files are not considered binary (in vanilly git)
37 cl_assert(!git_buf_text_contains_nul(&b));
39 b.ptr = data2; b.size = b.asize = data2len;
40 --
41 1.9.4.msysgit.0