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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 19, 2017 at 16:25 UTC 83de23cfea3730293c52072376b28d87b37d756b
1 file changed +18 -8
t/t4015-diff-whitespace.sh
+18 -8
@@ -1326,9 +1326,11 @@ test_expect_success 'set up whitespace tests' '
1326 line 2
1327 line 3
1328 line 4
1329 - long line 5
1329 + line 5
1330 long line 6
1331 long line 7
1332 + long line 8
1333 + long line 9
1334 EOF
1335 git add lines.txt &&
1336 git commit -m "add poetry" &&
@@ -1338,13 +1340,15 @@ test_expect_success 'set up whitespace tests' '
1340
1341 test_expect_success 'move detection ignoring whitespace ' '
1342 q_to_tab <<-\EOF >lines.txt &&
1341 - Qlong line 5
1343 Qlong line 6
1344 Qlong line 7
1345 + Qlong line 8
1346 + Qchanged long line 9
1347 line 1
1348 line 2
1349 line 3
1350 line 4
1351 + line 5
1352 EOF
1353 git diff HEAD --no-renames --color-moved --color |
1354 grep -v "index" |
@@ -1353,17 +1357,20 @@ test_expect_success 'move detection ignoring whitespace ' '
1357 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1358 <BOLD>--- a/lines.txt<RESET>
1359 <BOLD>+++ b/lines.txt<RESET>
1356 - <CYAN>@@ -1,7 +1,7 @@<RESET>
1357 - <GREEN>+<RESET> <GREEN>long line 5<RESET>
1360 + <CYAN>@@ -1,9 +1,9 @@<RESET>
1361 <GREEN>+<RESET> <GREEN>long line 6<RESET>
1362 <GREEN>+<RESET> <GREEN>long line 7<RESET>
1363 + <GREEN>+<RESET> <GREEN>long line 8<RESET>
1364 + <GREEN>+<RESET> <GREEN>changed long line 9<RESET>
1365 line 1<RESET>
1366 line 2<RESET>
1367 line 3<RESET>
1368 line 4<RESET>
1364 - <RED>-long line 5<RESET>
1369 + line 5<RESET>
1370 <RED>-long line 6<RESET>
1371 <RED>-long line 7<RESET>
1372 + <RED>-long line 8<RESET>
1373 + <RED>-long line 9<RESET>
1374 EOF
1375 test_cmp expected actual &&
1376
@@ -1374,17 +1381,20 @@ test_expect_success 'move detection ignoring whitespace ' '
1381 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1382 <BOLD>--- a/lines.txt<RESET>
1383 <BOLD>+++ b/lines.txt<RESET>
1377 - <CYAN>@@ -1,7 +1,7 @@<RESET>
1378 - <CYAN>+<RESET> <CYAN>long line 5<RESET>
1384 + <CYAN>@@ -1,9 +1,9 @@<RESET>
1385 <CYAN>+<RESET> <CYAN>long line 6<RESET>
1386 <CYAN>+<RESET> <CYAN>long line 7<RESET>
1387 + <CYAN>+<RESET> <CYAN>long line 8<RESET>
1388 + <GREEN>+<RESET> <GREEN>changed long line 9<RESET>
1389 line 1<RESET>
1390 line 2<RESET>
1391 line 3<RESET>
1392 line 4<RESET>
1385 - <MAGENTA>-long line 5<RESET>
1393 + line 5<RESET>
1394 <MAGENTA>-long line 6<RESET>
1395 <MAGENTA>-long line 7<RESET>
1396 + <MAGENTA>-long line 8<RESET>
1397 + <RED>-long line 9<RESET>
1398 EOF
1399 test_cmp expected actual
1400 '