@@ -802,7 +802,6 @@ test_expect_success 'combined diff with autocrlf conversion' '
802802# Start testing the colored format for whitespace checks
803803
804804test_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 &&
@@ -821,7 +820,7 @@ test_expect_success 'diff that introduces a line with only tabs' '
821820 echo "test" >x &&
822821 git commit -m "initial" x &&
823822 echo "{NTN}" | tr "NT" "\n\t" >>x &&
824- git -c color. diff=always diff | test_decode_color >current &&
823+ git diff --color | test_decode_color >current &&
825824
826825 cat >expected <<-\EOF &&
827826 <BOLD>diff --git a/x b/x<RESET>
@@ -851,7 +850,7 @@ test_expect_success 'diff that introduces and removes ws breakages' '
851850 echo "2. and a new line "
852851 } >x &&
853852
854- git -c color. diff=always diff |
853+ git diff --color |
855854 test_decode_color >current &&
856855
857856 cat >expected <<-\EOF &&
@@ -923,50 +922,50 @@ test_expect_success 'ws-error-highlight test setup' '
923922
924923test_expect_success ' test --ws-error-highlight option' '
925924
926- git -c color. diff=always diff --ws-error-highlight=default,old |
925+ git diff --color --ws-error-highlight=default,old |
927926 test_decode_color >current &&
928927 test_cmp expect.default-old current &&
929928
930- git -c color. diff=always diff --ws-error-highlight=all |
929+ git diff --color --ws-error-highlight=all |
931930 test_decode_color >current &&
932931 test_cmp expect.all current &&
933932
934- git -c color. diff=always diff --ws-error-highlight=none |
933+ git diff --color --ws-error-highlight=none |
935934 test_decode_color >current &&
936935 test_cmp expect.none current
937936
938937'
939938
940939test_expect_success ' test diff.wsErrorHighlight config' '
941940
942- git -c color. diff=always -c diff .wsErrorHighlight=default,old diff |
941+ git -c diff.wsErrorHighlight=default,old diff --color |
943942 test_decode_color >current &&
944943 test_cmp expect.default-old current &&
945944
946- git -c color. diff=always -c diff .wsErrorHighlight=all diff |
945+ git -c diff.wsErrorHighlight=all diff --color |
947946 test_decode_color >current &&
948947 test_cmp expect.all current &&
949948
950- git -c color. diff=always -c diff .wsErrorHighlight=none diff |
949+ git -c diff.wsErrorHighlight=none diff --color |
951950 test_decode_color >current &&
952951 test_cmp expect.none current
953952
954953'
955954
956955test_expect_success ' option overrides diff.wsErrorHighlight' '
957956
958- git -c color.diff=always -c diff.wsErrorHighlight=none \
959- diff --ws-error-highlight=default,old |
957+ git -c diff.wsErrorHighlight=none \
958+ diff --color -- ws-error-highlight=default,old |
960959 test_decode_color >current &&
961960 test_cmp expect.default-old current &&
962961
963- git -c color.diff=always -c diff.wsErrorHighlight=default \
964- diff --ws-error-highlight=all |
962+ git -c diff.wsErrorHighlight=default \
963+ diff --color -- ws-error-highlight=all |
965964 test_decode_color >current &&
966965 test_cmp expect.all current &&
967966
968- git -c color.diff=always -c diff.wsErrorHighlight=all \
969- diff --ws-error-highlight=none |
967+ git -c diff.wsErrorHighlight=all \
968+ diff --color -- ws-error-highlight=none |
970969 test_decode_color >current &&
971970 test_cmp expect.none current
972971
@@ -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
13431342EOF
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