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 <sunshine@sunshineco.com> Acked-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Mar 4, 2018 at 00:26 UTC 7f19def0fc254829839495f7fb44a7d99b161d3d
1 file changed +9 -10
t/t2028-worktree-move.sh
+9 -10
@@ -7,7 +7,8 @@ test_description='test git worktree move, remove, lock and unlock'
7 test_expect_success 'setup' '
8 test_commit init &&
9 git worktree add source &&
10 - git worktree list --porcelain | grep "^worktree" >actual &&
10 + git worktree list --porcelain >out &&
11 + grep "^worktree" out >actual &&
12 cat <<-EOF >expected &&
13 worktree $(pwd)
14 worktree $(pwd)/source
@@ -74,8 +75,9 @@ test_expect_success 'move worktree' '
75 toplevel="$(pwd)" &&
76 git worktree move source destination &&
77 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 &&
81 git -C destination log --format=%s >actual2 &&
82 echo init >expected2 &&
83 test_cmp expected2 actual2
@@ -86,11 +88,12 @@ test_expect_success 'move main worktree' '
88 '
89
90 test_expect_success 'move worktree to another dir' '
89 - toplevel="$(pwd)" &&
91 mkdir some-dir &&
92 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 &&
97 git -C some-dir/destination log --format=%s >actual2 &&
98 echo init >expected2 &&
99 test_cmp expected2 actual2
@@ -100,10 +103,6 @@ test_expect_success 'remove main worktree' '
103 test_must_fail git worktree remove .
104 '
105
103 -test_expect_success 'move some-dir/destination back' '
104 - git worktree move some-dir/destination destination
105 -'
106 -
106 test_expect_success 'remove locked worktree' '
107 git worktree lock destination &&
108 test_when_finished "git worktree unlock destination" &&