Skip to content

Commit 9720b30

Browse files
committed
Merge branch 'vn/xdiff-func-context'
"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
2 parents 39b8980 + 540d3eb commit 9720b30

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

xdiff/xemit.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,14 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
183183

184184
/*
185185
* We don't need additional context if
186-
* a whole function was added, possibly
187-
* starting with empty lines.
186+
* a whole function was added.
188187
*/
189-
while (i2 < xe->xdf2.nrec &&
190-
is_empty_rec(&xe->xdf2, i2))
188+
while (i2 < xe->xdf2.nrec) {
189+
if (match_func_rec(&xe->xdf2, xecfg, i2,
190+
dummy, sizeof(dummy)) >= 0)
191+
goto post_context_calculation;
191192
i2++;
192-
if (i2 < xe->xdf2.nrec &&
193-
match_func_rec(&xe->xdf2, xecfg, i2,
194-
dummy, sizeof(dummy)) >= 0)
195-
goto post_context_calculation;
193+
}
196194

197195
/*
198196
* Otherwise get more context from the

0 commit comments

Comments
 (0)