From 3ce8f08944e614813c7dfb212a88b7c4e3b443bc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 25 Mar 2006 12:16:17 -0800 Subject: built-in diff: minimum tweaks This fixes up a couple of minor issues with the real built-in diff to be more usable: - Omit ---/+++ header unless we emit diff output; - Detect and punt binary diff like GNU does; - Honor GIT_DIFF_OPTS minimally (only -u and --unified= are currently supported); - Omit line count of 1 from "@@ -l,k +m,n @@" hunk header (i.e. when k == 1 or n == 1) - Adjust testsuite for the lack of -p support. Signed-off-by: Junio C Hamano --- xdiff/xutils.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'xdiff') diff --git a/xdiff/xutils.c b/xdiff/xutils.c index b68afa25c1..8221806f78 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -245,20 +245,24 @@ int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, xdemitcb_t *ecb) { nb += xdl_num_out(buf + nb, c1 ? s1: 0); - memcpy(buf + nb, ",", 1); - nb += 1; + if (c1 != 1) { + memcpy(buf + nb, ",", 1); + nb += 1; - nb += xdl_num_out(buf + nb, c1); + nb += xdl_num_out(buf + nb, c1); + } memcpy(buf + nb, " +", 2); nb += 2; nb += xdl_num_out(buf + nb, c2 ? s2: 0); - memcpy(buf + nb, ",", 1); - nb += 1; + if (c2 != 1) { + memcpy(buf + nb, ",", 1); + nb += 1; - nb += xdl_num_out(buf + nb, c2); + nb += xdl_num_out(buf + nb, c2); + } memcpy(buf + nb, " @@\n", 4); nb += 4; -- cgit v1.2.3