From: Eric Sunshine Date: Sat, 16 Nov 2019 09:00:35 GMT Subject: Re: [PATCH 10/27] t4138: stop losing return codes of git commands Message-ID: In-Reply-To: On Thu, Nov 14, 2019 at 8:01 PM Denton Liu 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 > --- > diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh > @@ -17,8 +17,8 @@ test_expect_success setup ' > - git diff --no-index before after | > - sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch && > + test_must_fail git diff --no-index before after >patch1.patch.raw && > + sed -e "s/before/test-1/" -e "s/after/test-1/" patch1.patch.raw >patch1.patch && I think this is a semantically incorrect use of test_must_fail(). What you're interested here is that git-diff found differences (as opposed to not finding any), so you want to test its exit code which reflects whether or not the files were different. Hence, the following would be more appropriate: test_expect_code 1 git diff --no-index before after >patch1.patch.raw && Same comment applies to remaining changes in this patch.