t3201: finalize transitioning to using the branch name `main`

In 66713e84e71 (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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Dec 17, 2020 at 01:07 UTC 94287e788b3fd4fd4fd019f6642a91ea554a958b
1 file changed +42 -41
t/t3201-branch-contains.sh
+42 -41
@@ -10,51 +10,52 @@ test_expect_success setup '
10 git add file &&
11 test_tick &&
12 git commit -m initial &&
13 + git branch -M main &&
14 git branch side &&
15
16 echo 1 >file &&
17 test_tick &&
17 - git commit -a -m "second on master" &&
18 + git commit -a -m "second on main" &&
19
20 git checkout side &&
21 echo 1 >file &&
22 test_tick &&
23 git commit -a -m "second on side" &&
24
24 - git merge master
25 + git merge main
26
27 '
28
28 -test_expect_success 'branch --contains=master' '
29 +test_expect_success 'branch --contains=main' '
30
30 - git branch --contains=master >actual &&
31 + git branch --contains=main >actual &&
32 {
32 - echo " master" && echo "* side"
33 + echo " main" && echo "* side"
34 } >expect &&
35 test_cmp expect actual
36
37 '
38
38 -test_expect_success 'branch --contains master' '
39 +test_expect_success 'branch --contains main' '
40
40 - git branch --contains master >actual &&
41 + git branch --contains main >actual &&
42 {
42 - echo " master" && echo "* side"
43 + echo " main" && echo "* side"
44 } >expect &&
45 test_cmp expect actual
46
47 '
48
48 -test_expect_success 'branch --no-contains=master' '
49 +test_expect_success 'branch --no-contains=main' '
50
50 - git branch --no-contains=master >actual &&
51 + git branch --no-contains=main >actual &&
52 test_must_be_empty actual
53
54 '
55
55 -test_expect_success 'branch --no-contains master' '
56 +test_expect_success 'branch --no-contains main' '
57
57 - git branch --no-contains master >actual &&
58 + git branch --no-contains main >actual &&
59 test_must_be_empty actual
60
61 '
@@ -73,7 +74,7 @@ test_expect_success 'branch --no-contains=side' '
74
75 git branch --no-contains=side >actual &&
76 {
76 - echo " master"
77 + echo " main"
78 } >expect &&
79 test_cmp expect actual
80
@@ -81,9 +82,9 @@ test_expect_success 'branch --no-contains=side' '
82
83 test_expect_success 'branch --contains with pattern implies --list' '
84
84 - git branch --contains=master master >actual &&
85 + git branch --contains=main main >actual &&
86 {
86 - echo " master"
87 + echo " main"
88 } >expect &&
89 test_cmp expect actual
90
@@ -91,7 +92,7 @@ test_expect_success 'branch --contains with pattern implies --list' '
92
93 test_expect_success 'branch --no-contains with pattern implies --list' '
94
94 - git branch --no-contains=master master >actual &&
95 + git branch --no-contains=main main >actual &&
96 test_must_be_empty actual
97
98 '
@@ -100,7 +101,7 @@ test_expect_success 'side: branch --merged' '
101
102 git branch --merged >actual &&
103 {
103 - echo " master" &&
104 + echo " main" &&
105 echo "* side"
106 } >expect &&
107 test_cmp expect actual
@@ -109,9 +110,9 @@ test_expect_success 'side: branch --merged' '
110
111 test_expect_success 'branch --merged with pattern implies --list' '
112
112 - git branch --merged=side master >actual &&
113 + git branch --merged=side main >actual &&
114 {
114 - echo " master"
115 + echo " main"
116 } >expect &&
117 test_cmp expect actual
118
@@ -124,18 +125,18 @@ test_expect_success 'side: branch --no-merged' '
125
126 '
127
127 -test_expect_success 'master: branch --merged' '
128 +test_expect_success 'main: branch --merged' '
129
129 - git checkout master &&
130 + git checkout main &&
131 git branch --merged >actual &&
132 {
132 - echo "* master"
133 + echo "* main"
134 } >expect &&
135 test_cmp expect actual
136
137 '
138
138 -test_expect_success 'master: branch --no-merged' '
139 +test_expect_success 'main: branch --no-merged' '
140
141 git branch --no-merged >actual &&
142 {
@@ -147,22 +148,22 @@ test_expect_success 'master: branch --no-merged' '
148
149 test_expect_success 'branch --no-merged with pattern implies --list' '
150
150 - git branch --no-merged=master master >actual &&
151 + git branch --no-merged=main main >actual &&
152 test_must_be_empty actual
153
154 '
155
156 test_expect_success 'implicit --list conflicts with modification options' '
157
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
162
163 '
164
165 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} &&
167 blob=$(git hash-object -w --stdin <<-\EOF
168 Some blob
169 EOF
@@ -172,11 +173,11 @@ test_expect_success 'Assert that --contains only works on commits, not trees & b
173 '
174
175 test_expect_success 'multiple branch --contains' '
175 - git checkout -b side2 master &&
176 + git checkout -b side2 main &&
177 >feature &&
178 git add feature &&
179 git commit -m "add feature" &&
179 - git checkout -b next master &&
180 + git checkout -b next main &&
181 git merge side &&
182 git branch --contains side --contains side2 >actual &&
183 cat >expect <<-\EOF &&
@@ -188,9 +189,9 @@ test_expect_success 'multiple branch --contains' '
189 '
190
191 test_expect_success 'multiple branch --merged' '
191 - git branch --merged next --merged master >actual &&
192 + git branch --merged next --merged main >actual &&
193 cat >expect <<-\EOF &&
193 - master
194 + main
195 * next
196 side
197 EOF
@@ -200,13 +201,13 @@ test_expect_success 'multiple branch --merged' '
201 test_expect_success 'multiple branch --no-contains' '
202 git branch --no-contains side --no-contains side2 >actual &&
203 cat >expect <<-\EOF &&
203 - master
204 + main
205 EOF
206 test_cmp expect actual
207 '
208
209 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 &&
211 cat >expect <<-\EOF &&
212 side2
213 EOF
@@ -214,7 +215,7 @@ test_expect_success 'multiple branch --no-merged' '
215 '
216
217 test_expect_success 'branch --contains combined with --no-contains' '
217 - git checkout -b seen master &&
218 + git checkout -b seen main &&
219 git merge side &&
220 git merge side2 &&
221 git branch --contains side --no-contains side2 >actual &&
@@ -239,17 +240,17 @@ test_expect_success 'branch --merged combined with --no-merged' '
240 # that the latter walk does not mess up our flag to see if it was
241 # merged).
242 #
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"
245 # 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 &&
248 git branch zzz topic &&
249 git checkout topic &&
250 test_commit foo &&
251 git branch --merged topic >actual &&
252 cat >expect <<-\EOF &&
252 - master
253 + main
254 * topic
255 zzz
256 EOF