[PATCH 4/5] diff: don't include common trailing empty lines with -W
- From
René Scharfe <l.s.r@web.de>
- Date
- May 21, 2016, 18:46 UTC
- Message-ID
- <5740AD0C.505@web.de>
- In-Reply-To
- <5740AC28.6010202@web.de>
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 <l.s.r@web.de> --- xdiff/xemit.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/xdiff/xemit.c b/xdiff/xemit.c index 087956a..d0c0738 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -231,6 +231,9 @@ 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, xe->xdf1.nrec); + while (fe1 > 0 && + is_empty_rec(&xe->xdf1, xecfg, fe1 - 1)) + fe1--; if (fe1 < 0) fe1 = xe->xdf1.nrec; if (fe1 > e1) {
-- 2.8.3