Move buffer_is_binary() to xdiff-interface.h

We already have two instances where we want to determine if a buffer
contains binary data as opposed to text.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2007-06-05 03:36:11 +01:00
committed by Junio C Hamano
parent 20f1eb6b46
commit 6bfce93e04
4 changed files with 11 additions and 17 deletions

7
diff.c
View File

@ -1107,10 +1107,8 @@ static void setup_diff_attr_check(struct git_attr_check *check)
check->attr = attr_diff;
}
#define FIRST_FEW_BYTES 8000
static int file_is_binary(struct diff_filespec *one)
{
unsigned long sz;
struct git_attr_check attr_diff_check;
setup_diff_attr_check(&attr_diff_check);
@ -1127,10 +1125,7 @@ static int file_is_binary(struct diff_filespec *one)
return 0;
diff_populate_filespec(one, 0);
}
sz = one->size;
if (FIRST_FEW_BYTES < sz)
sz = FIRST_FEW_BYTES;
return !!memchr(one->data, 0, sz);
return buffer_is_binary(one->data, one->size);
}
static void builtin_diff(const char *name_a,