t4015: use --color with --color-moved
The tests for --color-moved write their output to a file, but doing so suppresses color output under "auto". Right now this is solved by running the whole script under "color.diff=always". In preparation for the behavior of "always" changing, let's explicitly enable color. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 3, 2017 at 09:41 UTC
269c73e8d3b0f95cb3acfd567069a032899ae3dc
1 file changed
+12
-13
t/t4015-diff-whitespace.sh
+12
-13
@@ -802,7 +802,6 @@ test_expect_success 'combined diff with autocrlf conversion' '
802
# Start testing the colored format for whitespace checks
803
804
test_expect_success 'setup diff colors' '
805
- git config color.diff always &&
805
git config color.diff.plain normal &&
806
git config color.diff.meta bold &&
807
git config color.diff.frag cyan &&
@@ -986,7 +985,7 @@ test_expect_success 'detect moved code, complete file' '
985
git mv test.c main.c &&
986
test_config color.diff.oldMoved "normal red" &&
987
test_config color.diff.newMoved "normal green" &&
989
- git diff HEAD --color-moved=zebra --no-renames | test_decode_color >actual &&
988
+ git diff HEAD --color-moved=zebra --color --no-renames | test_decode_color >actual &&
989
cat >expected <<-\EOF &&
990
<BOLD>diff --git a/main.c b/main.c<RESET>
991
<BOLD>new file mode 100644<RESET>
@@ -1087,7 +1086,7 @@ test_expect_success 'detect malicious moved code, inside file' '
1086
bar();
1087
}
1088
EOF
1090
- git diff HEAD --no-renames --color-moved=zebra| test_decode_color >actual &&
1089
+ git diff HEAD --no-renames --color-moved=zebra --color | test_decode_color >actual &&
1090
cat <<-\EOF >expected &&
1091
<BOLD>diff --git a/main.c b/main.c<RESET>
1092
<BOLD>index 27a619c..7cf9336 100644<RESET>
@@ -1136,7 +1135,7 @@ test_expect_success 'plain moved code, inside file' '
1135
test_config color.diff.oldMovedAlternative "blue" &&
1136
test_config color.diff.newMovedAlternative "yellow" &&
1137
# needs previous test as setup
1139
- git diff HEAD --no-renames --color-moved=plain| test_decode_color >actual &&
1138
+ git diff HEAD --no-renames --color-moved=plain --color | test_decode_color >actual &&
1139
cat <<-\EOF >expected &&
1140
<BOLD>diff --git a/main.c b/main.c<RESET>
1141
<BOLD>index 27a619c..7cf9336 100644<RESET>
@@ -1227,7 +1226,7 @@ test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
1226
test_config color.diff.newMovedDimmed "normal cyan" &&
1227
test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
1228
test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
1230
- git diff HEAD --no-renames --color-moved=dimmed_zebra |
1229
+ git diff HEAD --no-renames --color-moved=dimmed_zebra --color |
1230
grep -v "index" |
1231
test_decode_color >actual &&
1232
cat <<-\EOF >expected &&
@@ -1271,7 +1270,7 @@ test_expect_success 'cmd option assumes configured colored-moved' '
1270
test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
1271
test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
1272
test_config diff.colorMoved zebra &&
1274
- git diff HEAD --no-renames --color-moved |
1273
+ git diff HEAD --no-renames --color-moved --color |
1274
grep -v "index" |
1275
test_decode_color >actual &&
1276
cat <<-\EOF >expected &&
@@ -1343,7 +1342,7 @@ line 4
1342
EOF
1343
test_config color.diff.oldMoved "magenta" &&
1344
test_config color.diff.newMoved "cyan" &&
1346
- git diff HEAD --no-renames --color-moved |
1345
+ git diff HEAD --no-renames --color-moved --color |
1346
grep -v "index" |
1347
test_decode_color >actual &&
1348
cat <<-\EOF >expected &&
@@ -1364,7 +1363,7 @@ EOF
1363
EOF
1364
test_cmp expected actual &&
1365
1367
- git diff HEAD --no-renames -w --color-moved |
1366
+ git diff HEAD --no-renames -w --color-moved --color |
1367
grep -v "index" |
1368
test_decode_color >actual &&
1369
cat <<-\EOF >expected &&
@@ -1403,7 +1402,7 @@ test_expect_success '--color-moved block at end of diff output respects MIN_ALNU
1402
irrelevant_line
1403
EOF
1404
1406
- git diff HEAD --color-moved=zebra --no-renames |
1405
+ git diff HEAD --color-moved=zebra --color --no-renames |
1406
grep -v "index" |
1407
test_decode_color >actual &&
1408
cat >expected <<-\EOF &&
@@ -1442,7 +1441,7 @@ test_expect_success '--color-moved respects MIN_ALNUM_COUNT' '
1441
nineteen chars 456789
1442
EOF
1443
1445
- git diff HEAD --color-moved=zebra --no-renames |
1444
+ git diff HEAD --color-moved=zebra --color --no-renames |
1445
grep -v "index" |
1446
test_decode_color >actual &&
1447
cat >expected <<-\EOF &&
@@ -1485,7 +1484,7 @@ test_expect_success '--color-moved treats adjacent blocks as separate for MIN_AL
1484
7charsA
1485
EOF
1486
1488
- git diff HEAD --color-moved=zebra --no-renames | grep -v "index" | test_decode_color >actual &&
1487
+ git diff HEAD --color-moved=zebra --color --no-renames | grep -v "index" | test_decode_color >actual &&
1488
cat >expected <<-\EOF &&
1489
<BOLD>diff --git a/bar b/bar<RESET>
1490
<BOLD>--- a/bar<RESET>
@@ -1519,7 +1518,7 @@ test_expect_success 'move detection with submodules' '
1518
echo foul >bananas/recipe &&
1519
echo ripe >fruit.t &&
1520
1522
- git diff --submodule=diff --color-moved >actual &&
1521
+ git diff --submodule=diff --color-moved --color >actual &&
1522
1523
# no move detection as the moved line is across repository boundaries.
1524
test_decode_color <actual >decoded_actual &&
@@ -1527,7 +1526,7 @@ test_expect_success 'move detection with submodules' '
1526
! grep BRED decoded_actual &&
1527
1528
# nor did we mess with it another way
1530
- git diff --submodule=diff | test_decode_color >expect &&
1529
+ git diff --submodule=diff --color | test_decode_color >expect &&
1530
test_cmp expect decoded_actual
1531
'
1532