t4015: test the output of "diff --color-moved -b"
Commit fa5ba2c1dd (diff: fix infinite loop with --color-moved --ignore-space-change, 2017-10-12) added a test to make sure that "--color-moved -b" doesn't run forever, but the test in question doesn't actually have any moved lines in it. Let's scrap that test and add a variant of the existing "--color-moved -w" test, but this time we'll check that we find the move with whitespace changes, but not arbitrary whitespace additions. 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:26 UTC
d5aae1f7cdcb6211d7884838f30e3cd1266b605f
1 file changed
+64
-9
t/t4015-diff-whitespace.sh
+64
-9
@@ -1399,6 +1399,70 @@ test_expect_success 'move detection ignoring whitespace ' '
1399
test_cmp expected actual
1400
'
1401
1402
+test_expect_success 'move detection ignoring whitespace changes' '
1403
+ git reset --hard &&
1404
+ # Lines 6-8 have a space change, but 9 is new whitespace
1405
+ q_to_tab <<-\EOF >lines.txt &&
1406
+ longQline 6
1407
+ longQline 7
1408
+ longQline 8
1409
+ long liQne 9
1410
+ line 1
1411
+ line 2
1412
+ line 3
1413
+ line 4
1414
+ line 5
1415
+ EOF
1416
+
1417
+ git diff HEAD --no-renames --color-moved --color |
1418
+ grep -v "index" |
1419
+ test_decode_color >actual &&
1420
+ cat <<-\EOF >expected &&
1421
+ <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1422
+ <BOLD>--- a/lines.txt<RESET>
1423
+ <BOLD>+++ b/lines.txt<RESET>
1424
+ <CYAN>@@ -1,9 +1,9 @@<RESET>
1425
+ <GREEN>+<RESET><GREEN>long line 6<RESET>
1426
+ <GREEN>+<RESET><GREEN>long line 7<RESET>
1427
+ <GREEN>+<RESET><GREEN>long line 8<RESET>
1428
+ <GREEN>+<RESET><GREEN>long li ne 9<RESET>
1429
+ line 1<RESET>
1430
+ line 2<RESET>
1431
+ line 3<RESET>
1432
+ line 4<RESET>
1433
+ line 5<RESET>
1434
+ <RED>-long line 6<RESET>
1435
+ <RED>-long line 7<RESET>
1436
+ <RED>-long line 8<RESET>
1437
+ <RED>-long line 9<RESET>
1438
+ EOF
1439
+ test_cmp expected actual &&
1440
+
1441
+ git diff HEAD --no-renames -b --color-moved --color |
1442
+ grep -v "index" |
1443
+ test_decode_color >actual &&
1444
+ cat <<-\EOF >expected &&
1445
+ <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1446
+ <BOLD>--- a/lines.txt<RESET>
1447
+ <BOLD>+++ b/lines.txt<RESET>
1448
+ <CYAN>@@ -1,9 +1,9 @@<RESET>
1449
+ <CYAN>+<RESET><CYAN>long line 6<RESET>
1450
+ <CYAN>+<RESET><CYAN>long line 7<RESET>
1451
+ <CYAN>+<RESET><CYAN>long line 8<RESET>
1452
+ <GREEN>+<RESET><GREEN>long li ne 9<RESET>
1453
+ line 1<RESET>
1454
+ line 2<RESET>
1455
+ line 3<RESET>
1456
+ line 4<RESET>
1457
+ line 5<RESET>
1458
+ <MAGENTA>-long line 6<RESET>
1459
+ <MAGENTA>-long line 7<RESET>
1460
+ <MAGENTA>-long line 8<RESET>
1461
+ <RED>-long line 9<RESET>
1462
+ EOF
1463
+ test_cmp expected actual
1464
+'
1465
+
1466
test_expect_success 'clean up whitespace-test colors' '
1467
git config --unset color.diff.oldMoved &&
1468
git config --unset color.diff.newMoved
@@ -1549,13 +1613,4 @@ test_expect_success 'move detection with submodules' '
1613
test_cmp expect decoded_actual
1614
'
1615
1552
-test_expect_success 'move detection with whitespace changes' '
1553
- test_when_finished "git reset --hard" &&
1554
- test_seq 10 >test &&
1555
- git add test &&
1556
- sed s/3/42/ <test >test.tmp &&
1557
- mv test.tmp test &&
1558
- git -c diff.colormoved diff --ignore-space-change -- test
1559
-'
1560
-
1616
test_done