Whenever a git command is present in the upstream of a pipe, its failure
gets masked by piping. Hence we should avoid it for testing the
upstream git command. By writing out the output of the git command to
a file, we can test the exit codes of both the commands as a failure exit
code in any command is able to stop the && chain.
Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Prathamesh Chavan8 years agocommitted byJunio C Hamano
@ -92,11 +95,12 @@ test_expect_success '"list" all worktrees --porcelain from bare main' '
@@ -92,11 +95,12 @@ test_expect_success '"list" all worktrees --porcelain from bare main' '
'
test_expect_success '"list" all worktrees from linked with a bare main' '
echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect &&
git -C there worktree list | sed "s/ */ /g" >actual &&
git -C there worktree list >out &&
sed "s/ */ /g" <out >actual &&
test_cmp expect actual
'
@ -118,9 +122,11 @@ test_expect_success 'broken main worktree still at the top' '
@@ -118,9 +122,11 @@ test_expect_success 'broken main worktree still at the top' '
cd linked &&
echo "worktree $(pwd)" >expected &&
echo "ref: .broken" >../.git/HEAD &&
git worktree list --porcelain | head -n 3 >actual &&
git worktree list --porcelain >out &&
head -n 3 out >actual &&
test_cmp ../expected actual &&
git worktree list | head -n 1 >actual.2 &&
git worktree list >out &&
head -n 1 out >actual.2 &&
grep -F "(error)" actual.2
)
'
@ -134,7 +140,8 @@ test_expect_success 'linked worktrees are sorted' '
@@ -134,7 +140,8 @@ test_expect_success 'linked worktrees are sorted' '
test_commit new &&
git worktree add ../first &&
git worktree add ../second &&
git worktree list --porcelain | grep ^worktree >actual