On Thu, Nov 14, 2019 at 8:01 PM Denton Liu <liu.denton@xxxxxxxxx> wrote: > In a pipe, only the return code of the last command is used. Thus, all > other commands will have their return codes masked. Rewrite pipes so > that there are no git commands upstream so that we will know if a > command fails. > > Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx> > --- > diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh > @@ -285,9 +285,8 @@ test_expect_success 'overriding author from command line' ' > test_expect_success PERL 'interactive add' ' > - echo 7 | > - git commit --interactive | > - grep "What now" > + echo 7 | test_must_fail git commit --interactive >out && > + grep "What now" out > ' git-commit documentation does not talk about the command's exit code, so it's not immediately clear why this test should be using test_must_fail() for the invocation. The implementation of git-commit is more illuminating, showing that 1 is returned when there are no changes to commit, and 0 for a successful commit. So, that raises the question of whether this should be using "test_expect_code 1" rather than test_must_fail(), however, there is existing precedence which gives some guidance. In particular, the "nothing to commit" test of t7501-commit-basic-functionality.sh does use test_must_fail() when attempting to commit with no changes. It may make sense, therefore, to mention something about this in the commit message to save future readers from wondering why the command is "expected to fail".