Skip to content

Commit 83de23c

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ecd5125 commit 83de23c

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,9 +1326,11 @@ test_expect_success 'set up whitespace tests' '
13261326
line 2
13271327
line 3
13281328
line 4
1329-
long line 5
1329+
line 5
13301330
long line 6
13311331
long line 7
1332+
long line 8
1333+
long line 9
13321334
EOF
13331335
git add lines.txt &&
13341336
git commit -m "add poetry" &&
@@ -1338,13 +1340,15 @@ test_expect_success 'set up whitespace tests' '
13381340

13391341
test_expect_success 'move detection ignoring whitespace ' '
13401342
q_to_tab <<-\EOF >lines.txt &&
1341-
Qlong line 5
13421343
Qlong line 6
13431344
Qlong line 7
1345+
Qlong line 8
1346+
Qchanged long line 9
13441347
line 1
13451348
line 2
13461349
line 3
13471350
line 4
1351+
line 5
13481352
EOF
13491353
git diff HEAD --no-renames --color-moved --color |
13501354
grep -v "index" |
@@ -1353,17 +1357,20 @@ test_expect_success 'move detection ignoring whitespace ' '
13531357
<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
13541358
<BOLD>--- a/lines.txt<RESET>
13551359
<BOLD>+++ b/lines.txt<RESET>
1356-
<CYAN>@@ -1,7 +1,7 @@<RESET>
1357-
<GREEN>+<RESET> <GREEN>long line 5<RESET>
1360+
<CYAN>@@ -1,9 +1,9 @@<RESET>
13581361
<GREEN>+<RESET> <GREEN>long line 6<RESET>
13591362
<GREEN>+<RESET> <GREEN>long line 7<RESET>
1363+
<GREEN>+<RESET> <GREEN>long line 8<RESET>
1364+
<GREEN>+<RESET> <GREEN>changed long line 9<RESET>
13601365
line 1<RESET>
13611366
line 2<RESET>
13621367
line 3<RESET>
13631368
line 4<RESET>
1364-
<RED>-long line 5<RESET>
1369+
line 5<RESET>
13651370
<RED>-long line 6<RESET>
13661371
<RED>-long line 7<RESET>
1372+
<RED>-long line 8<RESET>
1373+
<RED>-long line 9<RESET>
13671374
EOF
13681375
test_cmp expected actual &&
13691376
@@ -1374,17 +1381,20 @@ test_expect_success 'move detection ignoring whitespace ' '
13741381
<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
13751382
<BOLD>--- a/lines.txt<RESET>
13761383
<BOLD>+++ b/lines.txt<RESET>
1377-
<CYAN>@@ -1,7 +1,7 @@<RESET>
1378-
<CYAN>+<RESET> <CYAN>long line 5<RESET>
1384+
<CYAN>@@ -1,9 +1,9 @@<RESET>
13791385
<CYAN>+<RESET> <CYAN>long line 6<RESET>
13801386
<CYAN>+<RESET> <CYAN>long line 7<RESET>
1387+
<CYAN>+<RESET> <CYAN>long line 8<RESET>
1388+
<GREEN>+<RESET> <GREEN>changed long line 9<RESET>
13811389
line 1<RESET>
13821390
line 2<RESET>
13831391
line 3<RESET>
13841392
line 4<RESET>
1385-
<MAGENTA>-long line 5<RESET>
1393+
line 5<RESET>
13861394
<MAGENTA>-long line 6<RESET>
13871395
<MAGENTA>-long line 7<RESET>
1396+
<MAGENTA>-long line 8<RESET>
1397+
<RED>-long line 9<RESET>
13881398
EOF
13891399
test_cmp expected actual
13901400
'

0 commit comments

Comments
 (0)