Skip to content

Commit 269c73e

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8fb8a94 commit 269c73e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ test_expect_success 'combined diff with autocrlf conversion' '
802802
# Start testing the colored format for whitespace checks
803803

804804
test_expect_success 'setup diff colors' '
805-
git config color.diff always &&
806805
git config color.diff.plain normal &&
807806
git config color.diff.meta bold &&
808807
git config color.diff.frag cyan &&
@@ -986,7 +985,7 @@ test_expect_success 'detect moved code, complete file' '
986985
git mv test.c main.c &&
987986
test_config color.diff.oldMoved "normal red" &&
988987
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 &&
990989
cat >expected <<-\EOF &&
991990
<BOLD>diff --git a/main.c b/main.c<RESET>
992991
<BOLD>new file mode 100644<RESET>
@@ -1087,7 +1086,7 @@ test_expect_success 'detect malicious moved code, inside file' '
10871086
bar();
10881087
}
10891088
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 &&
10911090
cat <<-\EOF >expected &&
10921091
<BOLD>diff --git a/main.c b/main.c<RESET>
10931092
<BOLD>index 27a619c..7cf9336 100644<RESET>
@@ -1136,7 +1135,7 @@ test_expect_success 'plain moved code, inside file' '
11361135
test_config color.diff.oldMovedAlternative "blue" &&
11371136
test_config color.diff.newMovedAlternative "yellow" &&
11381137
# 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 &&
11401139
cat <<-\EOF >expected &&
11411140
<BOLD>diff --git a/main.c b/main.c<RESET>
11421141
<BOLD>index 27a619c..7cf9336 100644<RESET>
@@ -1227,7 +1226,7 @@ test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
12271226
test_config color.diff.newMovedDimmed "normal cyan" &&
12281227
test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
12291228
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 |
12311230
grep -v "index" |
12321231
test_decode_color >actual &&
12331232
cat <<-\EOF >expected &&
@@ -1271,7 +1270,7 @@ test_expect_success 'cmd option assumes configured colored-moved' '
12711270
test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
12721271
test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
12731272
test_config diff.colorMoved zebra &&
1274-
git diff HEAD --no-renames --color-moved |
1273+
git diff HEAD --no-renames --color-moved --color |
12751274
grep -v "index" |
12761275
test_decode_color >actual &&
12771276
cat <<-\EOF >expected &&
@@ -1343,7 +1342,7 @@ line 4
13431342
EOF
13441343
test_config color.diff.oldMoved "magenta" &&
13451344
test_config color.diff.newMoved "cyan" &&
1346-
git diff HEAD --no-renames --color-moved |
1345+
git diff HEAD --no-renames --color-moved --color |
13471346
grep -v "index" |
13481347
test_decode_color >actual &&
13491348
cat <<-\EOF >expected &&
@@ -1364,7 +1363,7 @@ EOF
13641363
EOF
13651364
test_cmp expected actual &&
13661365
1367-
git diff HEAD --no-renames -w --color-moved |
1366+
git diff HEAD --no-renames -w --color-moved --color |
13681367
grep -v "index" |
13691368
test_decode_color >actual &&
13701369
cat <<-\EOF >expected &&
@@ -1403,7 +1402,7 @@ test_expect_success '--color-moved block at end of diff output respects MIN_ALNU
14031402
irrelevant_line
14041403
EOF
14051404
1406-
git diff HEAD --color-moved=zebra --no-renames |
1405+
git diff HEAD --color-moved=zebra --color --no-renames |
14071406
grep -v "index" |
14081407
test_decode_color >actual &&
14091408
cat >expected <<-\EOF &&
@@ -1442,7 +1441,7 @@ test_expect_success '--color-moved respects MIN_ALNUM_COUNT' '
14421441
nineteen chars 456789
14431442
EOF
14441443
1445-
git diff HEAD --color-moved=zebra --no-renames |
1444+
git diff HEAD --color-moved=zebra --color --no-renames |
14461445
grep -v "index" |
14471446
test_decode_color >actual &&
14481447
cat >expected <<-\EOF &&
@@ -1485,7 +1484,7 @@ test_expect_success '--color-moved treats adjacent blocks as separate for MIN_AL
14851484
7charsA
14861485
EOF
14871486
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 &&
14891488
cat >expected <<-\EOF &&
14901489
<BOLD>diff --git a/bar b/bar<RESET>
14911490
<BOLD>--- a/bar<RESET>
@@ -1519,15 +1518,15 @@ test_expect_success 'move detection with submodules' '
15191518
echo foul >bananas/recipe &&
15201519
echo ripe >fruit.t &&
15211520
1522-
git diff --submodule=diff --color-moved >actual &&
1521+
git diff --submodule=diff --color-moved --color >actual &&
15231522
15241523
# no move detection as the moved line is across repository boundaries.
15251524
test_decode_color <actual >decoded_actual &&
15261525
! grep BGREEN decoded_actual &&
15271526
! grep BRED decoded_actual &&
15281527
15291528
# 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 &&
15311530
test_cmp expect decoded_actual
15321531
'
15331532

0 commit comments

Comments
 (0)