From 83de23cfea3730293c52072376b28d87b37d756b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 19 Oct 2017 16:25:57 -0400 Subject: [PATCH] t4015: check "negative" case for "-w --color-moved" We test that lines with whitespace changes are not found by "--color-moved" by default, but are found if "-w" is added. Let's add one more twist: a line that has non-whitespace changes should not be marked as a pure move. This is perhaps an obvious case for us to get right (and we do), but as we add more whitespace tests, they will form a pattern of "make sure this case is a move and this other case is not". Note that we have to add a line to our moved block, since having a too-small block doesn't trigger the "moved" heuristics. And we also add a line of context to ensure that there's more context lines than moved lines (so the diff shows us moving the lines up, rather than moving the context down). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t4015-diff-whitespace.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 164b502405..503c9bc7f3 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -1326,9 +1326,11 @@ test_expect_success 'set up whitespace tests' ' line 2 line 3 line 4 - long line 5 + line 5 long line 6 long line 7 + long line 8 + long line 9 EOF git add lines.txt && git commit -m "add poetry" && @@ -1338,13 +1340,15 @@ test_expect_success 'set up whitespace tests' ' test_expect_success 'move detection ignoring whitespace ' ' q_to_tab <<-\EOF >lines.txt && - Qlong line 5 Qlong line 6 Qlong line 7 + Qlong line 8 + Qchanged long line 9 line 1 line 2 line 3 line 4 + line 5 EOF git diff HEAD --no-renames --color-moved --color | grep -v "index" | @@ -1353,17 +1357,20 @@ test_expect_success 'move detection ignoring whitespace ' ' diff --git a/lines.txt b/lines.txt --- a/lines.txt +++ b/lines.txt - @@ -1,7 +1,7 @@ - + long line 5 + @@ -1,9 +1,9 @@ + long line 6 + long line 7 + + long line 8 + + changed long line 9 line 1 line 2 line 3 line 4 - -long line 5 + line 5 -long line 6 -long line 7 + -long line 8 + -long line 9 EOF test_cmp expected actual && @@ -1374,17 +1381,20 @@ test_expect_success 'move detection ignoring whitespace ' ' diff --git a/lines.txt b/lines.txt --- a/lines.txt +++ b/lines.txt - @@ -1,7 +1,7 @@ - + long line 5 + @@ -1,9 +1,9 @@ + long line 6 + long line 7 + + long line 8 + + changed long line 9 line 1 line 2 line 3 line 4 - -long line 5 + line 5 -long line 6 -long line 7 + -long line 8 + -long line 9 EOF test_cmp expected actual ' -- 2.11.4.GIT