t4015: check "negative" case for "-w --color-moved"
We test that lines with whitespace changes are not found by "--color-moved" by default, but are found if "-w" is added. Let's add one more twist: a line that has non-whitespace changes should not be marked as a pure move. This is perhaps an obvious case for us to get right (and we do), but as we add more whitespace tests, they will form a pattern of "make sure this case is a move and this other case is not". Note that we have to add a line to our moved block, since having a too-small block doesn't trigger the "moved" heuristics. And we also add a line of context to ensure that there's more context lines than moved lines (so the diff shows us moving the lines up, rather than moving the context down). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ecd512582c
commit
83de23cfea
@ -1326,9 +1326,11 @@ test_expect_success 'set up whitespace tests' '
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
long line 5
|
||||
line 5
|
||||
long line 6
|
||||
long line 7
|
||||
long line 8
|
||||
long line 9
|
||||
EOF
|
||||
git add lines.txt &&
|
||||
git commit -m "add poetry" &&
|
||||
@ -1338,13 +1340,15 @@ test_expect_success 'set up whitespace tests' '
|
||||
|
||||
test_expect_success 'move detection ignoring whitespace ' '
|
||||
q_to_tab <<-\EOF >lines.txt &&
|
||||
Qlong line 5
|
||||
Qlong line 6
|
||||
Qlong line 7
|
||||
Qlong line 8
|
||||
Qchanged long line 9
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
EOF
|
||||
git diff HEAD --no-renames --color-moved --color |
|
||||
grep -v "index" |
|
||||
@ -1353,17 +1357,20 @@ test_expect_success 'move detection ignoring whitespace ' '
|
||||
<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
|
||||
<BOLD>--- a/lines.txt<RESET>
|
||||
<BOLD>+++ b/lines.txt<RESET>
|
||||
<CYAN>@@ -1,7 +1,7 @@<RESET>
|
||||
<GREEN>+<RESET> <GREEN>long line 5<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>changed long line 9<RESET>
|
||||
line 1<RESET>
|
||||
line 2<RESET>
|
||||
line 3<RESET>
|
||||
line 4<RESET>
|
||||
<RED>-long line 5<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 &&
|
||||
|
||||
@ -1374,17 +1381,20 @@ test_expect_success 'move detection ignoring whitespace ' '
|
||||
<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
|
||||
<BOLD>--- a/lines.txt<RESET>
|
||||
<BOLD>+++ b/lines.txt<RESET>
|
||||
<CYAN>@@ -1,7 +1,7 @@<RESET>
|
||||
<CYAN>+<RESET> <CYAN>long line 5<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>changed long line 9<RESET>
|
||||
line 1<RESET>
|
||||
line 2<RESET>
|
||||
line 3<RESET>
|
||||
line 4<RESET>
|
||||
<MAGENTA>-long line 5<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
|
||||
'
|
||||
|
Loading…
Reference in New Issue
Block a user