1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-22 17:56:09 +02:00

xdiff -W: relax end-of-file function detection

When adding a new function to the end of a file, it's enough to know
that 1) the addition is at the end of the file; and 2) there is a
function _somewhere_ in there.

If we had simply been changing the end of an existing function, then we
would also be deleting something from the old version.

This fixes the case where we add e.g.

	// Begin of dummy
	static int dummy(void)
	{
	}

to the end of the file.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Acked-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Vegard Nossum 2017-01-13 17:15:10 +01:00 committed by Junio C Hamano
parent d7dffce1ce
commit 540d3eb0eb

View 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