From 6d5badb2389d5d1d0752a230cd7ee74bb4043893 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Sat, 28 May 2016 17:00:28 +0200 Subject: xdiff: handle appended chunks better with -W If lines are added at the end of a file, diff -W shows the whole file. That's because get_func_line() only considers the pre-image and gives up if it sees a record index beyond its end. Consider the post-image as well to see if the added lines already make up a full function. If it doesn't then search for the previous function line by starting from the bottom of the pre-image, thereby avoiding to confuse get_func_line(). Reuse the existing label called "again", as it's exactly where we need to jump to when we're done handling the pre-context, but rename it to "post_context_calculation" in order to document its new purpose better. Reported-by: Junio C Hamano Initial-patch-by: Junio C Hamano Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- t/t4051-diff-function-context.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t4051-diff-function-context.sh') diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh index ca017255ba..4cff119b69 100755 --- a/t/t4051-diff-function-context.sh +++ b/t/t4051-diff-function-context.sh @@ -131,7 +131,7 @@ test_expect_success ' context includes end' ' grep "^[+].*End of second part" extended.diff ' -test_expect_failure ' context does not include other functions' ' +test_expect_success ' context does not include other functions' ' test $(grep -c "^[ +-].*Begin" extended.diff) -le 2 ' -- cgit v1.2.3