Skip to content

Commit 7f19def

Browse files
sunshinecogitster
authored andcommitted
t2028: fix minor error and issues in newly-added "worktree move" tests
Recently-added "git worktree move" tests include a minor error and a few small issues. Specifically: * checking non-existence of wrong file ("source" instead of "destination") * unneeded redirect (">empty") * unused variable ("toplevel") * restoring a worktree location by means of a separate test somewhat distant from the test which moved it rather than using test_when_finished() to restore it in a self-contained fashion * having git command on the left-hand-side of a pipe ("git foo | grep") Signed-off-by: Eric Sunshine <[email protected]> Acked-by: Duy Nguyen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee6763a commit 7f19def

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

t/t2028-worktree-move.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ test_description='test git worktree move, remove, lock and unlock'
77
test_expect_success 'setup' '
88
test_commit init &&
99
git worktree add source &&
10-
git worktree list --porcelain | grep "^worktree" >actual &&
10+
git worktree list --porcelain >out &&
11+
grep "^worktree" out >actual &&
1112
cat <<-EOF >expected &&
1213
worktree $(pwd)
1314
worktree $(pwd)/source
@@ -74,8 +75,9 @@ test_expect_success 'move worktree' '
7475
toplevel="$(pwd)" &&
7576
git worktree move source destination &&
7677
test_path_is_missing source &&
77-
git worktree list --porcelain | grep "^worktree.*/destination" &&
78-
! git worktree list --porcelain | grep "^worktree.*/source" >empty &&
78+
git worktree list --porcelain >out &&
79+
grep "^worktree.*/destination" out &&
80+
! grep "^worktree.*/source" out &&
7981
git -C destination log --format=%s >actual2 &&
8082
echo init >expected2 &&
8183
test_cmp expected2 actual2
@@ -86,11 +88,12 @@ test_expect_success 'move main worktree' '
8688
'
8789

8890
test_expect_success 'move worktree to another dir' '
89-
toplevel="$(pwd)" &&
9091
mkdir some-dir &&
9192
git worktree move destination some-dir &&
92-
test_path_is_missing source &&
93-
git worktree list --porcelain | grep "^worktree.*/some-dir/destination" &&
93+
test_when_finished "git worktree move some-dir/destination destination" &&
94+
test_path_is_missing destination &&
95+
git worktree list --porcelain >out &&
96+
grep "^worktree.*/some-dir/destination" out &&
9497
git -C some-dir/destination log --format=%s >actual2 &&
9598
echo init >expected2 &&
9699
test_cmp expected2 actual2
@@ -100,10 +103,6 @@ test_expect_success 'remove main worktree' '
100103
test_must_fail git worktree remove .
101104
'
102105

103-
test_expect_success 'move some-dir/destination back' '
104-
git worktree move some-dir/destination destination
105-
'
106-
107106
test_expect_success 'remove locked worktree' '
108107
git worktree lock destination &&
109108
test_when_finished "git worktree unlock destination" &&

0 commit comments

Comments
 (0)