23
test_cmp expect.upstream actual.upstream
24
}
25
26
+status_uno_is_clean () {
27
+ >status.expect &&
28
+ git status -uno --porcelain >status.actual &&
29
+ test_cmp status.expect status.actual
30
+}
31
+
32
test_expect_success 'setup' '
33
test_commit my_master &&
34
git init repo_a &&
61
test_might_fail git branch -D xyzzy &&
62
63
test_must_fail git checkout xyzzy &&
64
+ status_uno_is_clean &&
65
test_must_fail git rev-parse --verify refs/heads/xyzzy &&
66
test_branch master
67
'
71
test_might_fail git branch -D foo &&
72
73
test_must_fail git checkout foo &&
74
+ status_uno_is_clean &&
75
test_must_fail git rev-parse --verify refs/heads/foo &&
76
test_branch master
77
'
81
test_might_fail git branch -D bar &&
82
83
git checkout bar &&
84
+ status_uno_is_clean &&
85
test_branch bar &&
86
test_cmp_rev remotes/repo_a/bar HEAD &&
87
test_branch_upstream bar repo_a bar
92
test_might_fail git branch -D baz &&
93
94
git checkout baz &&
95
+ status_uno_is_clean &&
96
test_branch baz &&
97
test_cmp_rev remotes/other_b/baz HEAD &&
98
test_branch_upstream baz repo_b baz
100
101
test_expect_success '--no-guess suppresses branch auto-vivification' '
102
git checkout -B master &&
103
+ status_uno_is_clean &&
104
test_might_fail git branch -D bar &&
105
106
test_must_fail git checkout --no-guess bar &&
110
111
test_expect_success 'setup more remotes with unconventional refspecs' '
112
git checkout -B master &&
113
+ status_uno_is_clean &&
114
git init repo_c &&
115
(
116
cd repo_c &&
140
141
test_expect_success 'checkout of branch from multiple remotes fails #2' '
142
git checkout -B master &&
143
+ status_uno_is_clean &&
144
test_might_fail git branch -D bar &&
145
146
test_must_fail git checkout bar &&
147
+ status_uno_is_clean &&
148
test_must_fail git rev-parse --verify refs/heads/bar &&
149
test_branch master
150
'
151
152
test_expect_success 'checkout of branch from multiple remotes fails #3' '
153
git checkout -B master &&
154
+ status_uno_is_clean &&
155
test_might_fail git branch -D baz &&
156
157
test_must_fail git checkout baz &&
158
+ status_uno_is_clean &&
159
test_must_fail git rev-parse --verify refs/heads/baz &&
160
test_branch master
161
'
162
163
test_expect_success 'checkout of branch from a single remote succeeds #3' '
164
git checkout -B master &&
165
+ status_uno_is_clean &&
166
test_might_fail git branch -D spam &&
167
168
git checkout spam &&
169
+ status_uno_is_clean &&
170
test_branch spam &&
171
test_cmp_rev refs/remotes/extra_dir/repo_c/extra_dir/spam HEAD &&
172
test_branch_upstream spam repo_c spam
174
175
test_expect_success 'checkout of branch from a single remote succeeds #4' '
176
git checkout -B master &&
177
+ status_uno_is_clean &&
178
test_might_fail git branch -D eggs &&
179
180
git checkout eggs &&
181
+ status_uno_is_clean &&
182
test_branch eggs &&
183
test_cmp_rev refs/repo_d/eggs HEAD &&
184
test_branch_upstream eggs repo_d eggs
186
187
test_expect_success 'checkout of branch with a file having the same name fails' '
188
git checkout -B master &&
189
+ status_uno_is_clean &&
190
test_might_fail git branch -D spam &&
191
192
>spam &&
193
test_must_fail git checkout spam &&
194
+ status_uno_is_clean &&
195
test_must_fail git rev-parse --verify refs/heads/spam &&
196
test_branch master
197
'
198
199
test_expect_success 'checkout of branch with a file in subdir having the same name fails' '
200
git checkout -B master &&
201
+ status_uno_is_clean &&
202
test_might_fail git branch -D spam &&
203
204
>spam &&
205
mkdir sub &&
206
mv spam sub/spam &&
207
test_must_fail git -C sub checkout spam &&
208
+ status_uno_is_clean &&
209
test_must_fail git rev-parse --verify refs/heads/spam &&
210
test_branch master
211
'
212
213
test_expect_success 'checkout <branch> -- succeeds, even if a file with the same name exists' '
214
git checkout -B master &&
215
+ status_uno_is_clean &&
216
test_might_fail git branch -D spam &&
217
218
>spam &&
219
git checkout spam -- &&
220
+ status_uno_is_clean &&
221
test_branch spam &&
222
test_cmp_rev refs/remotes/extra_dir/repo_c/extra_dir/spam HEAD &&
223
test_branch_upstream spam repo_c spam
226
test_expect_success 'loosely defined local base branch is reported correctly' '
227
228
git checkout master &&
229
+ status_uno_is_clean &&
230
git branch strict &&
231
git branch loose &&
232
git commit --allow-empty -m "a bit more" &&
237
test_config branch.loose.merge master &&
238
239
git checkout strict | sed -e "s/strict/BRANCHNAME/g" >expect &&
240
+ status_uno_is_clean &&
241
git checkout loose | sed -e "s/loose/BRANCHNAME/g" >actual &&
242
+ status_uno_is_clean &&
243
244
test_cmp expect actual
245
'