Skip to content

Commit 425ae8a

Browse files
achlumagitster
authored andcommitted
t2400: avoid losing exit status to pipes
The exit code of the preceding command in a pipe is disregarded. So if that preceding command is a Git command that fails, the test would not fail. Instead, by saving the output of that Git command to a file, and removing the pipe, we make sure the test will fail if that Git command fails. Signed-off-by: Achu Luma <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e02ecfc commit 425ae8a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

t/t2400-worktree-add.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ test_expect_success 'put a worktree under rebase' '
490490
cd under-rebase &&
491491
set_fake_editor &&
492492
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
493-
git worktree list | grep "under-rebase.*detached HEAD"
493+
git worktree list >actual &&
494+
grep "under-rebase.*detached HEAD" actual
494495
)
495496
'
496497

@@ -531,7 +532,8 @@ test_expect_success 'checkout a branch under bisect' '
531532
git bisect start &&
532533
git bisect bad &&
533534
git bisect good HEAD~2 &&
534-
git worktree list | grep "under-bisect.*detached HEAD" &&
535+
git worktree list >actual &&
536+
grep "under-bisect.*detached HEAD" actual &&
535537
test_must_fail git worktree add new-bisect under-bisect &&
536538
! test -d new-bisect
537539
)

0 commit comments

Comments
 (0)