path: root/xdiff
diff options
authorRené Scharfe <>2016-05-28 15:03:16 (GMT)
committerJunio C Hamano <>2016-05-31 20:08:56 (GMT)
commit9e6a4cfc38aa81055d0b7d6fb94dc7b31809daa9 (patch)
treee03053b418d6223b8fa33714e43037e5ba7524b5 /xdiff
parent392f6d316623e8ecd6210248ba9ae2cabf07352b (diff)
xdiff: -W: don't include common trailing empty lines in context
Empty lines between functions are shown by diff -W, as it considers them to be part of the function preceding them. They are not interesting in most languages. The previous patch stopped showing them in the special case of a function added at the end of a file. Stop extending context to those empty lines by skipping back over them from the start of the next function. Signed-off-by: Rene Scharfe <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'xdiff')
1 files changed, 2 insertions, 0 deletions
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 29cec12..bfa53d3 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -231,6 +231,8 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
long fe1 = get_func_line(xe, xecfg, NULL,
xche->i1 + xche->chg1,
+ while (fe1 > 0 && is_empty_rec(&xe->xdf1, fe1 - 1))
+ fe1--;
if (fe1 < 0)
fe1 = xe->xdf1.nrec;
if (fe1 > e1) {