t4015: avoid git as a pipe input

In t4015 we have a pattern of git diff [<options, related to color>] | grep -v "index" | test_decode_color >actual && to produce output that we want to test against. This pattern was introduced in 86b452e2769 (diff.c: add dimming to moved line detection, 2017-06-30) as then the focus on getting the colors right. However the pattern used is not best practice as we do care about the exit code of Git. So let's not have Git as the upstream of a pipe. Piping the output of grep to some function is fine as we assume grep to be un-flawed in our test suite. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Jul 16, 2018 at 16:05 UTC 74cfa7bed96ea003e0a3ea20455096187c517b19
1 file changed +20 -30
t/t4015-diff-whitespace.sh
+20 -30
@@ -1271,9 +1271,8 @@ test_expect_success 'detect permutations inside moved code -- dimmed_zebra' '
1271 test_config color.diff.newMovedDimmed "normal cyan" &&
1272 test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
1273 test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
1274 - git diff HEAD --no-renames --color-moved=dimmed_zebra --color |
1275 - grep -v "index" |
1276 - test_decode_color >actual &&
1274 + git diff HEAD --no-renames --color-moved=dimmed_zebra --color >actual.raw &&
1275 + grep -v "index" actual.raw | test_decode_color >actual &&
1276 cat <<-\EOF >expected &&
1277 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1278 <BOLD>--- a/lines.txt<RESET>
@@ -1315,9 +1314,8 @@ test_expect_success 'cmd option assumes configured colored-moved' '
1314 test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
1315 test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
1316 test_config diff.colorMoved zebra &&
1318 - git diff HEAD --no-renames --color-moved --color |
1319 - grep -v "index" |
1320 - test_decode_color >actual &&
1317 + git diff HEAD --no-renames --color-moved --color >actual.raw &&
1318 + grep -v "index" actual.raw | test_decode_color >actual &&
1319 cat <<-\EOF >expected &&
1320 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1321 <BOLD>--- a/lines.txt<RESET>
@@ -1395,9 +1393,8 @@ test_expect_success 'move detection ignoring whitespace ' '
1393 line 4
1394 line 5
1395 EOF
1398 - git diff HEAD --no-renames --color-moved --color |
1399 - grep -v "index" |
1400 - test_decode_color >actual &&
1396 + git diff HEAD --no-renames --color-moved --color >actual.raw &&
1397 + grep -v "index" actual.raw | test_decode_color >actual &&
1398 cat <<-\EOF >expected &&
1399 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1400 <BOLD>--- a/lines.txt<RESET>
@@ -1419,9 +1416,8 @@ test_expect_success 'move detection ignoring whitespace ' '
1416 EOF
1417 test_cmp expected actual &&
1418
1422 - git diff HEAD --no-renames -w --color-moved --color |
1423 - grep -v "index" |
1424 - test_decode_color >actual &&
1419 + git diff HEAD --no-renames -w --color-moved --color >actual.raw &&
1420 + grep -v "index" actual.raw | test_decode_color >actual &&
1421 cat <<-\EOF >expected &&
1422 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1423 <BOLD>--- a/lines.txt<RESET>
@@ -1459,9 +1455,8 @@ test_expect_success 'move detection ignoring whitespace changes' '
1455 line 5
1456 EOF
1457
1462 - git diff HEAD --no-renames --color-moved --color |
1463 - grep -v "index" |
1464 - test_decode_color >actual &&
1458 + git diff HEAD --no-renames --color-moved --color >actual.raw &&
1459 + grep -v "index" actual.raw | test_decode_color >actual &&
1460 cat <<-\EOF >expected &&
1461 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1462 <BOLD>--- a/lines.txt<RESET>
@@ -1483,9 +1478,8 @@ test_expect_success 'move detection ignoring whitespace changes' '
1478 EOF
1479 test_cmp expected actual &&
1480
1486 - git diff HEAD --no-renames -b --color-moved --color |
1487 - grep -v "index" |
1488 - test_decode_color >actual &&
1481 + git diff HEAD --no-renames -b --color-moved --color >actual.raw &&
1482 + grep -v "index" actual.raw | test_decode_color >actual &&
1483 cat <<-\EOF >expected &&
1484 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1485 <BOLD>--- a/lines.txt<RESET>
@@ -1526,9 +1520,8 @@ test_expect_success 'move detection ignoring whitespace at eol' '
1520 # avoid cluttering the output with complaints about our eol whitespace
1521 test_config core.whitespace -blank-at-eol &&
1522
1529 - git diff HEAD --no-renames --color-moved --color |
1530 - grep -v "index" |
1531 - test_decode_color >actual &&
1523 + git diff HEAD --no-renames --color-moved --color >actual.raw &&
1524 + grep -v "index" actual.raw | test_decode_color >actual &&
1525 cat <<-\EOF >expected &&
1526 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1527 <BOLD>--- a/lines.txt<RESET>
@@ -1550,9 +1543,8 @@ test_expect_success 'move detection ignoring whitespace at eol' '
1543 EOF
1544 test_cmp expected actual &&
1545
1553 - git diff HEAD --no-renames --ignore-space-at-eol --color-moved --color |
1554 - grep -v "index" |
1555 - test_decode_color >actual &&
1546 + git diff HEAD --no-renames --ignore-space-at-eol --color-moved --color >actual.raw &&
1547 + grep -v "index" actual.raw | test_decode_color >actual &&
1548 cat <<-\EOF >expected &&
1549 <BOLD>diff --git a/lines.txt b/lines.txt<RESET>
1550 <BOLD>--- a/lines.txt<RESET>
@@ -1597,9 +1589,8 @@ test_expect_success '--color-moved block at end of diff output respects MIN_ALNU
1589 irrelevant_line
1590 EOF
1591
1600 - git diff HEAD --color-moved=zebra --color --no-renames |
1601 - grep -v "index" |
1602 - test_decode_color >actual &&
1592 + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw &&
1593 + grep -v "index" actual.raw | test_decode_color >actual &&
1594 cat >expected <<-\EOF &&
1595 <BOLD>diff --git a/bar b/bar<RESET>
1596 <BOLD>--- a/bar<RESET>
@@ -1636,9 +1627,8 @@ test_expect_success '--color-moved respects MIN_ALNUM_COUNT' '
1627 nineteen chars 456789
1628 EOF
1629
1639 - git diff HEAD --color-moved=zebra --color --no-renames |
1640 - grep -v "index" |
1641 - test_decode_color >actual &&
1630 + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw &&
1631 + grep -v "index" actual.raw | test_decode_color >actual &&
1632 cat >expected <<-\EOF &&
1633 <BOLD>diff --git a/bar b/bar<RESET>
1634 <BOLD>--- a/bar<RESET>