t5505: 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 four test cases. 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 97b913681b361ed072494e2f03c10ea4e4750cfb
1 file changed +78 -78
t/t5505-remote.sh
+78 -78
@@ -7,7 +7,7 @@ test_description='git remote porcelain-ish'
7 setup_repository () {
8 mkdir "$1" && (
9 cd "$1" &&
10 - git init &&
10 + git init -b main &&
11 >file &&
12 git add file &&
13 test_tick &&
@@ -17,7 +17,7 @@ setup_repository () {
17 git add elif &&
18 test_tick &&
19 git commit -m "Second" &&
20 - git checkout master
20 + git checkout main
21 )
22 }
23
@@ -60,8 +60,8 @@ test_expect_success C_LOCALE_OUTPUT 'remote information for the origin' '
60 (
61 cd test &&
62 tokens_match origin "$(git remote)" &&
63 - check_remote_track origin master side &&
64 - check_tracking_branch origin HEAD master side
63 + check_remote_track origin main side &&
64 + check_tracking_branch origin HEAD main side
65 )
66 '
67
@@ -70,7 +70,7 @@ test_expect_success 'add another remote' '
70 cd test &&
71 git remote add -f second ../two &&
72 tokens_match "origin second" "$(git remote)" &&
73 - check_tracking_branch second master side another &&
73 + check_tracking_branch second main side another &&
74 git for-each-ref "--format=%(refname)" refs/remotes |
75 sed -e "/^refs\/remotes\/origin\//d" \
76 -e "/^refs\/remotes\/second\//d" >actual &&
@@ -81,8 +81,8 @@ test_expect_success 'add another remote' '
81 test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' '
82 (
83 cd test &&
84 - check_remote_track origin master side &&
85 - check_remote_track second master side another
84 + check_remote_track origin main side &&
85 + check_remote_track second main side another
86 )
87 '
88
@@ -99,7 +99,7 @@ test_expect_success 'remote forces tracking branches' '
99 test_expect_success 'remove remote' '
100 (
101 cd test &&
102 - git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
102 + git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/main &&
103 git remote rm second
104 )
105 '
@@ -108,7 +108,7 @@ test_expect_success C_LOCALE_OUTPUT 'remove remote' '
108 (
109 cd test &&
110 tokens_match origin "$(git remote)" &&
111 - check_remote_track origin master side &&
111 + check_remote_track origin main side &&
112 git for-each-ref "--format=%(refname)" refs/remotes |
113 sed -e "/^refs\/remotes\/origin\//d" >actual &&
114 test_must_be_empty actual
@@ -121,13 +121,13 @@ test_expect_success 'remove remote protects local branches' '
121 cat >expect1 <<-\EOF &&
122 Note: A branch outside the refs/remotes/ hierarchy was not removed;
123 to delete it, use:
124 - git branch -d master
124 + git branch -d main
125 EOF
126 cat >expect2 <<-\EOF &&
127 Note: Some branches outside the refs/remotes/ hierarchy were not removed;
128 to delete them, use:
129 git branch -d foobranch
130 - git branch -d master
130 + git branch -d main
131 EOF
132 git tag footag &&
133 git config --add remote.oops.fetch "+refs/*:refs/*" &&
@@ -153,7 +153,7 @@ test_expect_success 'remove errors out early when deleting non-existent branch'
153
154 test_expect_success 'remove remote with a branch without configured merge' '
155 test_when_finished "(
156 - git -C test checkout master;
156 + git -C test checkout main;
157 git -C test branch -D two;
158 git -C test config --remove-section remote.two;
159 git -C test config --remove-section branch.second;
@@ -163,9 +163,9 @@ test_expect_success 'remove remote with a branch without configured merge' '
163 cd test &&
164 git remote add two ../two &&
165 git fetch two &&
166 - git checkout -b second two/master^0 &&
166 + git checkout -b second two/main^0 &&
167 git config branch.second.remote two &&
168 - git checkout master &&
168 + git checkout main &&
169 git remote rm two
170 )
171 '
@@ -211,7 +211,7 @@ cat >test/expect <<EOF
211 * remote origin
212 Fetch URL: $(pwd)/one
213 Push URL: $(pwd)/one
214 - HEAD branch: master
214 + HEAD branch: main
215 Remote branches:
216 main new (next fetch will store in remotes/origin)
217 side tracked
@@ -221,32 +221,32 @@ cat >test/expect <<EOF
221 octopus merges with remote topic-a
222 and with remote topic-b
223 and with remote topic-c
224 - rebase rebases onto remote master
224 + rebase rebases onto remote main
225 Local refs configured for 'git push':
226 main pushes to main (local out of date)
227 main pushes to upstream (create)
228 * remote two
229 Fetch URL: ../two
230 Push URL: ../three
231 - HEAD branch: master
231 + HEAD branch: main
232 Local refs configured for 'git push':
233 ahead forces to main (fast-forwardable)
234 main pushes to another (up to date)
235 EOF
236
237 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'show' '
237 +test_expect_success 'show' '
238 (
239 cd test &&
240 - git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
240 + git config --add remote.origin.fetch refs/heads/main:refs/heads/upstream &&
241 git fetch &&
242 - git checkout -b ahead origin/master &&
242 + git checkout -b ahead origin/main &&
243 echo 1 >>file &&
244 test_tick &&
245 git commit -m update file &&
246 - git checkout master &&
247 - git branch --track octopus origin/master &&
248 - git branch --track rebase origin/master &&
249 - git branch -d -r origin/master &&
246 + git checkout main &&
247 + git branch --track octopus origin/main &&
248 + git branch --track rebase origin/main &&
249 + git branch -d -r origin/main &&
250 git config --add remote.two.url ../two &&
251 git config --add remote.two.pushurl ../three &&
252 git config branch.rebase.rebase true &&
@@ -258,10 +258,10 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'show' '
258 git commit -m update file
259 ) &&
260 git config --add remote.origin.push : &&
261 - git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
261 + git config --add remote.origin.push refs/heads/main:refs/heads/upstream &&
262 git config --add remote.origin.push +refs/tags/lastbackup &&
263 - git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
264 - git config --add remote.two.push refs/heads/master:refs/heads/another &&
263 + git config --add remote.two.push +refs/heads/ahead:refs/heads/main &&
264 + git config --add remote.two.push refs/heads/main:refs/heads/another &&
265 git remote show origin two >output &&
266 git branch -d rebase octopus &&
267 test_i18ncmp expect output
@@ -274,7 +274,7 @@ cat >test/expect <<EOF
274 Push URL: $(pwd)/one
275 HEAD branch: (not queried)
276 Remote branches: (status not queried)
277 - master
277 + main
278 side
279 Local branches configured for 'git pull':
280 ahead merges with remote main
@@ -285,7 +285,7 @@ cat >test/expect <<EOF
285 refs/tags/lastbackup forces to refs/tags/lastbackup
286 EOF
287
288 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'show -n' '
288 +test_expect_success 'show -n' '
289 mv one one.unreachable &&
290 (
291 cd test &&
@@ -322,18 +322,18 @@ test_expect_success 'set-head --auto' '
322 (
323 cd test &&
324 git remote set-head --auto origin &&
325 - echo refs/remotes/origin/master >expect &&
325 + echo refs/remotes/origin/main >expect &&
326 git symbolic-ref refs/remotes/origin/HEAD >output &&
327 test_cmp expect output
328 )
329 '
330
331 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'set-head --auto has no problem w/multiple HEADs' '
331 +test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
332 (
333 cd test &&
334 git fetch two "refs/heads/*:refs/remotes/two/*" &&
335 git remote set-head --auto two >output 2>&1 &&
336 - echo "two/HEAD set to master" >expect &&
336 + echo "two/HEAD set to main" >expect &&
337 test_i18ncmp expect output
338 )
339 '
@@ -347,7 +347,7 @@ test_expect_success 'set-head explicit' '
347 cd test &&
348 git remote set-head origin side2 &&
349 git symbolic-ref refs/remotes/origin/HEAD >output &&
350 - git remote set-head origin master &&
350 + git remote set-head origin main &&
351 test_cmp expect output
352 )
353 '
@@ -394,7 +394,7 @@ test_expect_success 'add --mirror && prune' '
394
395 test_expect_success 'add --mirror=fetch' '
396 mkdir mirror-fetch &&
397 - git init mirror-fetch/parent &&
397 + git init -b main mirror-fetch/parent &&
398 (
399 cd mirror-fetch/parent &&
400 test_commit one
@@ -410,7 +410,7 @@ test_expect_success 'fetch mirrors act as mirrors during fetch' '
410 (
411 cd mirror-fetch/parent &&
412 git branch new &&
413 - git branch -m master renamed
413 + git branch -m main renamed
414 ) &&
415 (
416 cd mirror-fetch/child &&
@@ -424,7 +424,7 @@ test_expect_success 'fetch mirrors can prune' '
424 (
425 cd mirror-fetch/child &&
426 git remote prune parent &&
427 - test_must_fail git rev-parse --verify refs/heads/master
427 + test_must_fail git rev-parse --verify refs/heads/main
428 )
429 '
430
@@ -465,7 +465,7 @@ test_expect_success 'fetch mirror respects specific branches' '
465 test_expect_success 'add --mirror=push' '
466 mkdir mirror-push &&
467 git init --bare mirror-push/public &&
468 - git init mirror-push/private &&
468 + git init -b main mirror-push/private &&
469 (
470 cd mirror-push/private &&
471 test_commit one &&
@@ -477,14 +477,14 @@ test_expect_success 'push mirrors act as mirrors during push' '
477 (
478 cd mirror-push/private &&
479 git branch new &&
480 - git branch -m master renamed &&
480 + git branch -m main renamed &&
481 git push public
482 ) &&
483 (
484 cd mirror-push/private &&
485 git rev-parse --verify refs/heads/new &&
486 git rev-parse --verify refs/heads/renamed &&
487 - test_must_fail git rev-parse --verify refs/heads/master
487 + test_must_fail git rev-parse --verify refs/heads/main
488 )
489 '
490
@@ -610,10 +610,10 @@ test_expect_success 'reject --no-no-tags' '
610 '
611
612 cat >one/expect <<\EOF
613 - apis/master
613 + apis/main
614 apis/side
615 drosophila/another
616 - drosophila/master
616 + drosophila/main
617 drosophila/side
618 EOF
619
@@ -630,11 +630,11 @@ test_expect_success 'update' '
630
631 cat >one/expect <<\EOF
632 drosophila/another
633 - drosophila/master
633 + drosophila/main
634 drosophila/side
635 - manduca/master
635 + manduca/main
636 manduca/side
637 - megaloprepus/master
637 + megaloprepus/main
638 megaloprepus/side
639 EOF
640
@@ -673,11 +673,11 @@ test_expect_success 'update --prune' '
673 '
674
675 cat >one/expect <<-\EOF
676 - apis/master
676 + apis/main
677 apis/side
678 - manduca/master
678 + manduca/main
679 manduca/side
680 - megaloprepus/master
680 + megaloprepus/main
681 megaloprepus/side
682 EOF
683
@@ -697,7 +697,7 @@ test_expect_success 'update default' '
697
698 cat >one/expect <<\EOF
699 drosophila/another
700 - drosophila/master
700 + drosophila/main
701 drosophila/side
702 EOF
703
@@ -751,14 +751,14 @@ test_expect_success 'rename a remote' '
751 git clone one four &&
752 (
753 cd four &&
754 - git config branch.master.pushRemote origin &&
754 + git config branch.main.pushRemote origin &&
755 git remote rename origin upstream &&
756 test -z "$(git for-each-ref refs/remotes/origin)" &&
757 - test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
758 - test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
757 + test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" &&
758 + test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" &&
759 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
760 - test "$(git config branch.master.remote)" = "upstream" &&
761 - test "$(git config branch.master.pushRemote)" = "upstream" &&
760 + test "$(git config branch.main.remote)" = "upstream" &&
761 + test "$(git config branch.main.pushRemote)" = "upstream" &&
762 test "$(git config --global remote.pushDefault)" = "origin"
763 )
764 '
@@ -804,7 +804,7 @@ test_expect_success 'rename does not update a non-default fetch refspec' '
804 git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
805 git remote rename origin upstream &&
806 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
807 - git rev-parse -q origin/master
807 + git rev-parse -q origin/main
808 )
809 '
810
@@ -824,7 +824,7 @@ test_expect_success 'rename a remote with name prefix of other remote' '
824 cd four.three &&
825 git remote add o git://example.com/repo.git &&
826 git remote rename o upstream &&
827 - test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
827 + test "$(git rev-parse origin/main)" = "$(git rev-parse main)"
828 )
829 '
830
@@ -840,11 +840,11 @@ test_expect_success 'remove a remote' '
840 git clone one four.five &&
841 (
842 cd four.five &&
843 - git config branch.master.pushRemote origin &&
843 + git config branch.main.pushRemote origin &&
844 git remote remove origin &&
845 test -z "$(git for-each-ref refs/remotes/origin)" &&
846 - test_must_fail git config branch.master.remote &&
847 - test_must_fail git config branch.master.pushRemote &&
846 + test_must_fail git config branch.main.remote &&
847 + test_must_fail git config branch.main.pushRemote &&
848 test "$(git config --global remote.pushDefault)" = "origin"
849 )
850 '
@@ -885,9 +885,9 @@ test_expect_success 'remove a remote removes repo remote.pushDefault but keeps g
885
886 cat >remotes_origin <<EOF
887 URL: $(pwd)/one
888 -Push: refs/heads/master:refs/heads/upstream
888 +Push: refs/heads/main:refs/heads/upstream
889 Push: refs/heads/next:refs/heads/upstream2
890 -Pull: refs/heads/master:refs/heads/origin
890 +Pull: refs/heads/main:refs/heads/origin
891 Pull: refs/heads/next:refs/heads/origin2
892 EOF
893
@@ -903,11 +903,11 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
903 test_path_is_missing .git/remotes/origin &&
904 test "$(git config remote.origin.url)" = "$origin_url" &&
905 cat >push_expected <<-\EOF &&
906 - refs/heads/master:refs/heads/upstream
906 + refs/heads/main:refs/heads/upstream
907 refs/heads/next:refs/heads/upstream2
908 EOF
909 cat >fetch_expected <<-\EOF &&
910 - refs/heads/master:refs/heads/origin
910 + refs/heads/main:refs/heads/origin
911 refs/heads/next:refs/heads/origin2
912 EOF
913 git config --get-all remote.origin.push >push_actual &&
@@ -923,12 +923,12 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
923 (
924 cd six &&
925 git remote rm origin &&
926 - echo "$origin_url" >.git/branches/origin &&
926 + echo "$origin_url#main" >.git/branches/origin &&
927 git remote rename origin origin &&
928 test_path_is_missing .git/branches/origin &&
929 test "$(git config remote.origin.url)" = "$origin_url" &&
930 - test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" &&
931 - test "$(git config remote.origin.push)" = "HEAD:refs/heads/master"
930 + test "$(git config remote.origin.fetch)" = "refs/heads/main:refs/heads/origin" &&
931 + test "$(git config remote.origin.push)" = "HEAD:refs/heads/main"
932 )
933 '
934
@@ -951,7 +951,7 @@ test_expect_success 'remote prune to cause a dangling symref' '
951 (
952 cd one &&
953 git checkout side2 &&
954 - git branch -D master
954 + git branch -D main
955 ) &&
956 (
957 cd eight &&
@@ -994,22 +994,22 @@ test_expect_success 'remote set-branches' '
994 EOF
995 sort <<-\EOF >expect.replace &&
996 +refs/heads/maint:refs/remotes/scratch/maint
997 - +refs/heads/master:refs/remotes/scratch/master
997 + +refs/heads/main:refs/remotes/scratch/main
998 +refs/heads/next:refs/remotes/scratch/next
999 EOF
1000 sort <<-\EOF >expect.add-two &&
1001 +refs/heads/maint:refs/remotes/scratch/maint
1002 - +refs/heads/master:refs/remotes/scratch/master
1002 + +refs/heads/main:refs/remotes/scratch/main
1003 +refs/heads/next:refs/remotes/scratch/next
1004 +refs/heads/seen:refs/remotes/scratch/seen
1005 +refs/heads/t/topic:refs/remotes/scratch/t/topic
1006 EOF
1007 sort <<-\EOF >expect.setup-ffonly &&
1008 - refs/heads/master:refs/remotes/scratch/master
1008 + refs/heads/main:refs/remotes/scratch/main
1009 +refs/heads/next:refs/remotes/scratch/next
1010 EOF
1011 sort <<-\EOF >expect.respect-ffonly &&
1012 - refs/heads/master:refs/remotes/scratch/master
1012 + refs/heads/main:refs/remotes/scratch/main
1013 +refs/heads/next:refs/remotes/scratch/next
1014 +refs/heads/seen:refs/remotes/scratch/seen
1015 EOF
@@ -1025,7 +1025,7 @@ test_expect_success 'remote set-branches' '
1025 git config --get-all remote.scratch.fetch >config-result &&
1026 sort <config-result >../actual.add &&
1027
1028 - git remote set-branches scratch maint master next &&
1028 + git remote set-branches scratch maint main next &&
1029 git config --get-all remote.scratch.fetch >config-result &&
1030 sort <config-result >../actual.replace &&
1031
@@ -1035,7 +1035,7 @@ test_expect_success 'remote set-branches' '
1035
1036 git config --unset-all remote.scratch.fetch &&
1037 git config remote.scratch.fetch \
1038 - refs/heads/master:refs/remotes/scratch/master &&
1038 + refs/heads/main:refs/remotes/scratch/main &&
1039 git config --add remote.scratch.fetch \
1040 +refs/heads/next:refs/remotes/scratch/next &&
1041 git config --get-all remote.scratch.fetch >config-result &&
@@ -1055,14 +1055,14 @@ test_expect_success 'remote set-branches' '
1055
1056 test_expect_success 'remote set-branches with --mirror' '
1057 echo "+refs/*:refs/*" >expect.initial &&
1058 - echo "+refs/heads/master:refs/heads/master" >expect.replace &&
1058 + echo "+refs/heads/main:refs/heads/main" >expect.replace &&
1059 git clone --mirror .git/ setbranches-mirror &&
1060 (
1061 cd setbranches-mirror &&
1062 git remote rename origin scratch &&
1063 git config --get-all remote.scratch.fetch >../actual.initial &&
1064
1065 - git remote set-branches scratch heads/master &&
1065 + git remote set-branches scratch heads/main &&
1066 git config --get-all remote.scratch.fetch >../actual.replace
1067 ) &&
1068 test_cmp expect.initial actual.initial &&
@@ -1308,7 +1308,7 @@ test_extra_arg () {
1308 test_extra_arg add nick url
1309 test_extra_arg rename origin newname
1310 test_extra_arg remove origin
1311 -test_extra_arg set-head origin master
1311 +test_extra_arg set-head origin main
1312 # set-branches takes any number of args
1313 test_extra_arg get-url origin newurl
1314 test_extra_arg set-url origin newurl oldurl
@@ -1325,7 +1325,7 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' '
1325 test_when_finished "(cd test && git tag -d some-tag)" &&
1326 (
1327 cd test &&
1328 - git tag -a -m "Some tag" some-tag master &&
1328 + git tag -a -m "Some tag" some-tag main &&
1329 exit_with=true &&
1330 for type in commit tag tree blob
1331 do
@@ -1348,10 +1348,10 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' '
1348 )
1349 '
1350
1351 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
1351 +test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
1352 (
1353 cd two &&
1354 - git tag -a -m "Some tag" my-tag master &&
1354 + git tag -a -m "Some tag" my-tag main &&
1355 git update-ref refs/trees/my-head-tree HEAD^{tree} &&
1356 git update-ref refs/blobs/my-file-blob HEAD:file
1357 ) &&