combine-diff: handle binary files as binary
commit4d5f34719970274990cded2201957eb2262bca10
authorJeff King <peff@peff.net>
Mon, 23 May 2011 20:27:34 +0000 (23 16:27 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2011 22:43:43 +0000 (23 15:43 -0700)
tree244a8649d9783237d7d83f123946593cd57a3b3f
parentc95b99bb5d5f3aed88f8154371a813ebd0d2fa1d
combine-diff: handle binary files as binary

The combined diff code path is totally different from the
regular diff code path, and didn't handle binary files at
all. The results of a combined diff on a binary file could
range from annoying (since we spewed binary garbage,
possibly upsetting the user's terminal), to wrong (embedded
NULs caused us to show incorrect diffs, with lines truncated
at the NUL character), to potential security problems
(embedded NULs could interfere with "-z" output, possibly
defeating policy hooks which parse diff output).

Instead, we consider a combined diff to be binary if any of
the input blobs is binary. To show a binary combined diff,
we indicate "Binary blobs differ"; the "index" meta line
will show which parents had which blob.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
combine-diff.c
t/t4048-diff-combined-binary.sh [new file with mode: 0755]