1
0
mirror of https://github.com/git/git.git synced 2024-09-30 16:01:40 +02:00

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>
This commit is contained in:
Jeff King 2017-10-19 16:26:31 -04:00 committed by Junio C Hamano
parent 83de23cfea
commit d5aae1f7cd

@ -1399,6 +1399,70 @@ test_expect_success 'move detection ignoring whitespace ' '
test_cmp expected actual
'
test_expect_success 'move detection ignoring whitespace changes' '
git reset --hard &&
# Lines 6-8 have a space change, but 9 is new whitespace
q_to_tab <<-\EOF >lines.txt &&
longQline 6
longQline 7
longQline 8
long liQne 9
line 1
line 2
line 3
line 4
line 5
EOF
git diff HEAD --no-renames --color-moved --color |
grep -v "index" |
test_decode_color >actual &&
cat <<-\EOF >expected &&
<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
<BOLD>--- a/lines.txt<RESET>
<BOLD>+++ b/lines.txt<RESET>
<CYAN>@@ -1,9 +1,9 @@<RESET>
<GREEN>+<RESET><GREEN>long line 6<RESET>
<GREEN>+<RESET><GREEN>long line 7<RESET>
<GREEN>+<RESET><GREEN>long line 8<RESET>
<GREEN>+<RESET><GREEN>long li ne 9<RESET>
line 1<RESET>
line 2<RESET>
line 3<RESET>
line 4<RESET>
line 5<RESET>
<RED>-long line 6<RESET>
<RED>-long line 7<RESET>
<RED>-long line 8<RESET>
<RED>-long line 9<RESET>
EOF
test_cmp expected actual &&
git diff HEAD --no-renames -b --color-moved --color |
grep -v "index" |
test_decode_color >actual &&
cat <<-\EOF >expected &&
<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
<BOLD>--- a/lines.txt<RESET>
<BOLD>+++ b/lines.txt<RESET>
<CYAN>@@ -1,9 +1,9 @@<RESET>
<CYAN>+<RESET><CYAN>long line 6<RESET>
<CYAN>+<RESET><CYAN>long line 7<RESET>
<CYAN>+<RESET><CYAN>long line 8<RESET>
<GREEN>+<RESET><GREEN>long li ne 9<RESET>
line 1<RESET>
line 2<RESET>
line 3<RESET>
line 4<RESET>
line 5<RESET>
<MAGENTA>-long line 6<RESET>
<MAGENTA>-long line 7<RESET>
<MAGENTA>-long line 8<RESET>
<RED>-long line 9<RESET>
EOF
test_cmp expected actual
'
test_expect_success 'clean up whitespace-test colors' '
git config --unset color.diff.oldMoved &&
git config --unset color.diff.newMoved
@ -1549,13 +1613,4 @@ test_expect_success 'move detection with submodules' '
test_cmp expect decoded_actual
'
test_expect_success 'move detection with whitespace changes' '
test_when_finished "git reset --hard" &&
test_seq 10 >test &&
git add test &&
sed s/3/42/ <test >test.tmp &&
mv test.tmp test &&
git -c diff.colormoved diff --ignore-space-change -- test
'
test_done