diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2013-08-19 18:46:26 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2013-08-19 18:46:26 -0500 |
| commit | c0b01b7572232bd6c0cd848e9b92ed8a8d678bcf (patch) | |
| tree | 8e553e46bd1608bf596faa629437a5cf371a0c40 /src | |
| parent | 5e1fb2828a496d70c5c200b01e2fb0062268f468 (diff) | |
| download | libgit2-c0b01b7572232bd6c0cd848e9b92ed8a8d678bcf.tar.gz | |
Skip UTF-8 BOM in binary detection
When a git_buf contains a UTF-8 BOM, the three bytes comprising
that BOM are treated as unprintable characters. For a small git_buf,
the three BOM characters overwhelm the printable characters. This
is problematic when trying to check out a small file as the CR/LF
filtering will not apply.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buf_text.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/buf_text.c b/src/buf_text.c index 472339def..ecf592b51 100644 --- a/src/buf_text.c +++ b/src/buf_text.c @@ -170,8 +170,14 @@ int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings) bool git_buf_text_is_binary(const git_buf *buf) { const char *scan = buf->ptr, *end = buf->ptr + buf->size; + git_bom_t bom; int printable = 0, nonprintable = 0; + scan += git_buf_text_detect_bom(&bom, buf, 0); + + if (bom > GIT_BOM_UTF8) + return 1; + while (scan < end) { unsigned char c = *scan++; |
