@@ -20,27 +20,29 @@ test_expect_success 'rev-parse --git-common-dir on main worktree' '
20
20
21
21
test_expect_success ' rev-parse --git-path objects linked worktree' '
22
22
echo "$(git rev-parse --show-toplevel)/.git/objects" >expect &&
23
- test_when_finished "rm -rf linked-tree && git worktree prune" &&
23
+ test_when_finished "rm -rf linked-tree actual expect && git worktree prune" &&
24
24
git worktree add --detach linked-tree master &&
25
25
git -C linked-tree rev-parse --git-path objects >actual &&
26
26
test_cmp expect actual
27
27
'
28
28
29
29
test_expect_success ' "list" all worktrees from main' '
30
30
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
31
- test_when_finished "rm -rf here && git worktree prune" &&
31
+ test_when_finished "rm -rf here out actual expect && git worktree prune" &&
32
32
git worktree add --detach here master &&
33
33
echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect &&
34
- git worktree list | sed "s/ */ /g" >actual &&
34
+ git worktree list >out &&
35
+ sed "s/ */ /g" <out >actual &&
35
36
test_cmp expect actual
36
37
'
37
38
38
39
test_expect_success ' "list" all worktrees from linked' '
39
40
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
40
- test_when_finished "rm -rf here && git worktree prune" &&
41
+ test_when_finished "rm -rf here out actual expect && git worktree prune" &&
41
42
git worktree add --detach here master &&
42
43
echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect &&
43
- git -C here worktree list | sed "s/ */ /g" >actual &&
44
+ git -C here worktree list >out &&
45
+ sed "s/ */ /g" <out >actual &&
44
46
test_cmp expect actual
45
47
'
46
48
@@ -49,7 +51,7 @@ test_expect_success '"list" all worktrees --porcelain' '
49
51
echo "HEAD $(git rev-parse HEAD)" >>expect &&
50
52
echo "branch $(git symbolic-ref HEAD)" >>expect &&
51
53
echo >>expect &&
52
- test_when_finished "rm -rf here && git worktree prune" &&
54
+ test_when_finished "rm -rf here actual expect && git worktree prune" &&
53
55
git worktree add --detach here master &&
54
56
echo "worktree $(git -C here rev-parse --show-toplevel)" >>expect &&
55
57
echo "HEAD $(git rev-parse HEAD)" >>expect &&
@@ -69,16 +71,17 @@ test_expect_success 'bare repo setup' '
69
71
'
70
72
71
73
test_expect_success ' "list" all worktrees from bare main' '
72
- test_when_finished "rm -rf there && git -C bare1 worktree prune" &&
74
+ test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" &&
73
75
git -C bare1 worktree add --detach ../there master &&
74
76
echo "$(pwd)/bare1 (bare)" >expect &&
75
77
echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect &&
76
- git -C bare1 worktree list | sed "s/ */ /g" >actual &&
78
+ git -C bare1 worktree list >out &&
79
+ sed "s/ */ /g" <out >actual &&
77
80
test_cmp expect actual
78
81
'
79
82
80
83
test_expect_success ' "list" all worktrees --porcelain from bare main' '
81
- test_when_finished "rm -rf there && git -C bare1 worktree prune" &&
84
+ test_when_finished "rm -rf there actual expect && git -C bare1 worktree prune" &&
82
85
git -C bare1 worktree add --detach ../there master &&
83
86
echo "worktree $(pwd)/bare1" >expect &&
84
87
echo "bare" >>expect &&
@@ -92,11 +95,12 @@ test_expect_success '"list" all worktrees --porcelain from bare main' '
92
95
'
93
96
94
97
test_expect_success ' "list" all worktrees from linked with a bare main' '
95
- test_when_finished "rm -rf there && git -C bare1 worktree prune" &&
98
+ test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" &&
96
99
git -C bare1 worktree add --detach ../there master &&
97
100
echo "$(pwd)/bare1 (bare)" >expect &&
98
101
echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect &&
99
- git -C there worktree list | sed "s/ */ /g" >actual &&
102
+ git -C there worktree list >out &&
103
+ sed "s/ */ /g" <out >actual &&
100
104
test_cmp expect actual
101
105
'
102
106
@@ -118,9 +122,11 @@ test_expect_success 'broken main worktree still at the top' '
118
122
cd linked &&
119
123
echo "worktree $(pwd)" >expected &&
120
124
echo "ref: .broken" >../.git/HEAD &&
121
- git worktree list --porcelain | head -n 3 >actual &&
125
+ git worktree list --porcelain >out &&
126
+ head -n 3 out >actual &&
122
127
test_cmp ../expected actual &&
123
- git worktree list | head -n 1 >actual.2 &&
128
+ git worktree list >out &&
129
+ head -n 1 out >actual.2 &&
124
130
grep -F "(error)" actual.2
125
131
)
126
132
'
@@ -134,7 +140,8 @@ test_expect_success 'linked worktrees are sorted' '
134
140
test_commit new &&
135
141
git worktree add ../first &&
136
142
git worktree add ../second &&
137
- git worktree list --porcelain | grep ^worktree >actual
143
+ git worktree list --porcelain >out &&
144
+ grep ^worktree out >actual
138
145
) &&
139
146
cat >expected <<-EOF &&
140
147
worktree $(pwd)/sorted/main
0 commit comments