Skip to content

Commit 94287e7

Browse files
dschogitster
authored andcommitted
t3201: finalize transitioning to using the branch name main
In 66713e8 (tests: prepare aligned mentions of the default branch name, 2020-10-23), we started that transition, trying to prepare for a time when `git init` would use that name for the initial branch. Even if that time has not arrived, we can complete the transition by making the test script independent of the default branch name. This also allows us to drop the `PREPARE_FOR_MAIN_BRANCH` prereq from one test case. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec9779b commit 94287e7

File tree

1 file changed

+42
-41
lines changed

1 file changed

+42
-41
lines changed

t/t3201-branch-contains.sh

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,52 @@ test_expect_success setup '
1010
git add file &&
1111
test_tick &&
1212
git commit -m initial &&
13+
git branch -M main &&
1314
git branch side &&
1415
1516
echo 1 >file &&
1617
test_tick &&
17-
git commit -a -m "second on master" &&
18+
git commit -a -m "second on main" &&
1819
1920
git checkout side &&
2021
echo 1 >file &&
2122
test_tick &&
2223
git commit -a -m "second on side" &&
2324
24-
git merge master
25+
git merge main
2526
2627
'
2728

28-
test_expect_success 'branch --contains=master' '
29+
test_expect_success 'branch --contains=main' '
2930
30-
git branch --contains=master >actual &&
31+
git branch --contains=main >actual &&
3132
{
32-
echo " master" && echo "* side"
33+
echo " main" && echo "* side"
3334
} >expect &&
3435
test_cmp expect actual
3536
3637
'
3738

38-
test_expect_success 'branch --contains master' '
39+
test_expect_success 'branch --contains main' '
3940
40-
git branch --contains master >actual &&
41+
git branch --contains main >actual &&
4142
{
42-
echo " master" && echo "* side"
43+
echo " main" && echo "* side"
4344
} >expect &&
4445
test_cmp expect actual
4546
4647
'
4748

48-
test_expect_success 'branch --no-contains=master' '
49+
test_expect_success 'branch --no-contains=main' '
4950
50-
git branch --no-contains=master >actual &&
51+
git branch --no-contains=main >actual &&
5152
test_must_be_empty actual
5253
5354
'
5455

55-
test_expect_success 'branch --no-contains master' '
56+
test_expect_success 'branch --no-contains main' '
5657
57-
git branch --no-contains master >actual &&
58+
git branch --no-contains main >actual &&
5859
test_must_be_empty actual
5960
6061
'
@@ -73,25 +74,25 @@ test_expect_success 'branch --no-contains=side' '
7374
7475
git branch --no-contains=side >actual &&
7576
{
76-
echo " master"
77+
echo " main"
7778
} >expect &&
7879
test_cmp expect actual
7980
8081
'
8182

8283
test_expect_success 'branch --contains with pattern implies --list' '
8384
84-
git branch --contains=master master >actual &&
85+
git branch --contains=main main >actual &&
8586
{
86-
echo " master"
87+
echo " main"
8788
} >expect &&
8889
test_cmp expect actual
8990
9091
'
9192

9293
test_expect_success 'branch --no-contains with pattern implies --list' '
9394
94-
git branch --no-contains=master master >actual &&
95+
git branch --no-contains=main main >actual &&
9596
test_must_be_empty actual
9697
9798
'
@@ -100,7 +101,7 @@ test_expect_success 'side: branch --merged' '
100101
101102
git branch --merged >actual &&
102103
{
103-
echo " master" &&
104+
echo " main" &&
104105
echo "* side"
105106
} >expect &&
106107
test_cmp expect actual
@@ -109,9 +110,9 @@ test_expect_success 'side: branch --merged' '
109110

110111
test_expect_success 'branch --merged with pattern implies --list' '
111112
112-
git branch --merged=side master >actual &&
113+
git branch --merged=side main >actual &&
113114
{
114-
echo " master"
115+
echo " main"
115116
} >expect &&
116117
test_cmp expect actual
117118
@@ -124,18 +125,18 @@ test_expect_success 'side: branch --no-merged' '
124125
125126
'
126127

127-
test_expect_success 'master: branch --merged' '
128+
test_expect_success 'main: branch --merged' '
128129
129-
git checkout master &&
130+
git checkout main &&
130131
git branch --merged >actual &&
131132
{
132-
echo "* master"
133+
echo "* main"
133134
} >expect &&
134135
test_cmp expect actual
135136
136137
'
137138

138-
test_expect_success 'master: branch --no-merged' '
139+
test_expect_success 'main: branch --no-merged' '
139140
140141
git branch --no-merged >actual &&
141142
{
@@ -147,22 +148,22 @@ test_expect_success 'master: branch --no-merged' '
147148

148149
test_expect_success 'branch --no-merged with pattern implies --list' '
149150
150-
git branch --no-merged=master master >actual &&
151+
git branch --no-merged=main main >actual &&
151152
test_must_be_empty actual
152153
153154
'
154155

155156
test_expect_success 'implicit --list conflicts with modification options' '
156157
157-
test_must_fail git branch --contains=master -d &&
158-
test_must_fail git branch --contains=master -m foo &&
159-
test_must_fail git branch --no-contains=master -d &&
160-
test_must_fail git branch --no-contains=master -m foo
158+
test_must_fail git branch --contains=main -d &&
159+
test_must_fail git branch --contains=main -m foo &&
160+
test_must_fail git branch --no-contains=main -d &&
161+
test_must_fail git branch --no-contains=main -m foo
161162
162163
'
163164

164165
test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
165-
test_must_fail git branch --contains master^{tree} &&
166+
test_must_fail git branch --contains main^{tree} &&
166167
blob=$(git hash-object -w --stdin <<-\EOF
167168
Some blob
168169
EOF
@@ -172,11 +173,11 @@ test_expect_success 'Assert that --contains only works on commits, not trees & b
172173
'
173174

174175
test_expect_success 'multiple branch --contains' '
175-
git checkout -b side2 master &&
176+
git checkout -b side2 main &&
176177
>feature &&
177178
git add feature &&
178179
git commit -m "add feature" &&
179-
git checkout -b next master &&
180+
git checkout -b next main &&
180181
git merge side &&
181182
git branch --contains side --contains side2 >actual &&
182183
cat >expect <<-\EOF &&
@@ -188,9 +189,9 @@ test_expect_success 'multiple branch --contains' '
188189
'
189190

190191
test_expect_success 'multiple branch --merged' '
191-
git branch --merged next --merged master >actual &&
192+
git branch --merged next --merged main >actual &&
192193
cat >expect <<-\EOF &&
193-
master
194+
main
194195
* next
195196
side
196197
EOF
@@ -200,21 +201,21 @@ test_expect_success 'multiple branch --merged' '
200201
test_expect_success 'multiple branch --no-contains' '
201202
git branch --no-contains side --no-contains side2 >actual &&
202203
cat >expect <<-\EOF &&
203-
master
204+
main
204205
EOF
205206
test_cmp expect actual
206207
'
207208

208209
test_expect_success 'multiple branch --no-merged' '
209-
git branch --no-merged next --no-merged master >actual &&
210+
git branch --no-merged next --no-merged main >actual &&
210211
cat >expect <<-\EOF &&
211212
side2
212213
EOF
213214
test_cmp expect actual
214215
'
215216

216217
test_expect_success 'branch --contains combined with --no-contains' '
217-
git checkout -b seen master &&
218+
git checkout -b seen main &&
218219
git merge side &&
219220
git merge side2 &&
220221
git branch --contains side --no-contains side2 >actual &&
@@ -239,17 +240,17 @@ test_expect_success 'branch --merged combined with --no-merged' '
239240
# that the latter walk does not mess up our flag to see if it was
240241
# merged).
241242
#
242-
# Here "topic" tracks "master" with one extra commit, and "zzz" points to the
243-
# same tip as master The name "zzz" must come alphabetically after "topic"
243+
# Here "topic" tracks "main" with one extra commit, and "zzz" points to the
244+
# same tip as main The name "zzz" must come alphabetically after "topic"
244245
# as we process them in that order.
245-
test_expect_success PREPARE_FOR_MAIN_BRANCH 'branch --merged with --verbose' '
246-
git branch --track topic master &&
246+
test_expect_success 'branch --merged with --verbose' '
247+
git branch --track topic main &&
247248
git branch zzz topic &&
248249
git checkout topic &&
249250
test_commit foo &&
250251
git branch --merged topic >actual &&
251252
cat >expect <<-\EOF &&
252-
master
253+
main
253254
* topic
254255
zzz
255256
EOF

0 commit comments

Comments
 (0)