diff options
author | Jeff King <peff@peff.net> | 2017-10-19 16:26:31 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-21 21:11:08 +0900 |
commit | d5aae1f7cdcb6211d7884838f30e3cd1266b605f (patch) | |
tree | 14e25e7a72437067fad7752c067b7d47850c0ce8 | |
parent | t4015: check "negative" case for "-w --color-moved" (diff) | |
download | tgif-d5aae1f7cdcb6211d7884838f30e3cd1266b605f.tar.xz |
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>
-rwxr-xr-x | t/t4015-diff-whitespace.sh | 73 |
1 files 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 && + <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 |