Skip to content

Commit d5aae1f

Browse files
peffgitster
authored andcommitted
t4015: test the output of "diff --color-moved -b"
Commit fa5ba2c (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 83de23c commit d5aae1f

File tree

1 file changed

+64
-9
lines changed

1 file changed

+64
-9
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,70 @@ test_expect_success 'move detection ignoring whitespace ' '
13991399
test_cmp expected actual
14001400
'
14011401

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+
14021466
test_expect_success 'clean up whitespace-test colors' '
14031467
git config --unset color.diff.oldMoved &&
14041468
git config --unset color.diff.newMoved
@@ -1549,13 +1613,4 @@ test_expect_success 'move detection with submodules' '
15491613
test_cmp expect decoded_actual
15501614
'
15511615

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-
15611616
test_done

0 commit comments

Comments
 (0)