Merge branch 'rs/xdiff-merge-overlapping-hunks-for-W-context'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Sep 2016 22:15:26 +0000 (15:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Sep 2016 22:15:26 +0000 (15:15 -0700)
"git diff -W" output needs to extend the context backward to
include the header line of the current function and also forward to
include the body of the entire current function up to the header
line of the next one. This process may have to merge to adjacent
hunks, but the code forgot to do so in some cases.

* rs/xdiff-merge-overlapping-hunks-for-W-context:
xdiff: fix merging of hunks with -W context and -u context

1  2 
xdiff/xemit.c
diff --combined xdiff/xemit.c
index b52b4b9c1ee3ba3c6b94594af68a275e458bebaf,50790291742f318a594422af73645d240056ab2f..7389ce41022dbee5776d44a937e8bcf780656f42
  
  #include "xinclude.h"
  
 -
 -
 -
 -static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec);
 -static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb);
 -
 -
 -
 -
  static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec) {
  
        *rec = xdf->recs[ri]->ptr;
@@@ -239,7 -248,7 +239,7 @@@ int xdl_emit_diff(xdfenv_t *xe, xdchang
                        if (xche->next) {
                                long l = XDL_MIN(xche->next->i1,
                                                 xe->xdf1.nrec - 1);
-                               if (l <= e1 ||
+                               if (l - xecfg->ctxlen <= e1 ||
                                    get_func_line(xe, xecfg, NULL, l, e1) < 0) {
                                        xche = xche->next;
                                        goto post_context_calculation;