From d5aae1f7cdcb6211d7884838f30e3cd1266b605f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 19 Oct 2017 16:26:31 -0400 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- t/t4015-diff-whitespace.sh | 73 +++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 503c9bc7f3..1f54816c6b 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -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 && + diff --git a/lines.txt b/lines.txt + --- a/lines.txt + +++ b/lines.txt + @@ -1,9 +1,9 @@ + +long line 6 + +long line 7 + +long line 8 + +long li ne 9 + line 1 + line 2 + line 3 + line 4 + line 5 + -long line 6 + -long line 7 + -long line 8 + -long line 9 + EOF + test_cmp expected actual && + + git diff HEAD --no-renames -b --color-moved --color | + grep -v "index" | + test_decode_color >actual && + cat <<-\EOF >expected && + diff --git a/lines.txt b/lines.txt + --- a/lines.txt + +++ b/lines.txt + @@ -1,9 +1,9 @@ + +long line 6 + +long line 7 + +long line 8 + +long li ne 9 + line 1 + line 2 + line 3 + line 4 + line 5 + -long line 6 + -long line 7 + -long line 8 + -long line 9 + 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.tmp && - mv test.tmp test && - git -c diff.colormoved diff --ignore-space-change -- test -' - test_done