Merge branch 'vn/xdiff-func-context'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 21:57:17 +0000 (13:57 -0800)
"git diff -W" has been taught to handle the case where a new
function is added at the end of the file better.

* vn/xdiff-func-context:
xdiff -W: relax end-of-file function detection

xdiff/xemit.c
index 7389ce41022dbee5776d44a937e8bcf780656f42..8c88dbde3827ce9d1b5e4f95287513514b80fac1 100644 (file)
@@ -183,16 +183,14 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 
                                /*
                                 * We don't need additional context if
-                                * a whole function was added, possibly
-                                * starting with empty lines.
+                                * a whole function was added.
                                 */
-                               while (i2 < xe->xdf2.nrec &&
-                                      is_empty_rec(&xe->xdf2, i2))
+                               while (i2 < xe->xdf2.nrec) {
+                                       if (match_func_rec(&xe->xdf2, xecfg, i2,
+                                               dummy, sizeof(dummy)) >= 0)
+                                               goto post_context_calculation;
                                        i2++;
-                               if (i2 < xe->xdf2.nrec &&
-                                   match_func_rec(&xe->xdf2, xecfg, i2,
-                                                  dummy, sizeof(dummy)) >= 0)
-                                       goto post_context_calculation;
+                               }
 
                                /*
                                 * Otherwise get more context from the