t3200: finish transitioning to the initial branch name `main`

In 56300ff356b (t3200: prepare for `main` being shorter than `master`, 2020-10-23) and in 66713e84e71 (tests: prepare aligned mentions of the default branch name, 2020-10-23), we started to prepare t3200 for a new world where `git init` uses the branch name `main` for the initial branch. We do not even have to wait for that new world: we can easily ensure that that branch name is used, independent of the exact name `git init` will give the initial branch, so let's do that. This also lets us remove the `PREPARE_FOR_MAIN_BRANCH` prereq from three test cases in that script. 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 ec9779bcd82be98fbea22f6a6ca03b7bef70d80f
1 file changed +133 -132
t/t3200-branch.sh
+133 -132
@@ -12,6 +12,7 @@ test_expect_success 'prepare a trivial repository' '
12 echo Hello >A &&
13 git update-index --add A &&
14 git commit -m "Initial commit." &&
15 + git branch -M main &&
16 echo World >>A &&
17 git update-index --add A &&
18 git commit -m "Second commit." &&
@@ -27,8 +28,8 @@ test_expect_success 'branch -h in broken repository' '
28 mkdir broken &&
29 (
30 cd broken &&
30 - git init &&
31 - >.git/refs/heads/master &&
31 + git init -b main &&
32 + >.git/refs/heads/main &&
33 test_expect_code 129 git branch -h >usage 2>&1
34 ) &&
35 test_i18ngrep "[Uu]sage" broken/usage
@@ -42,8 +43,8 @@ test_expect_success 'git branch a/b/c should create a branch' '
43 git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c
44 '
45
45 -test_expect_success 'git branch mb master... should create a branch' '
46 - git branch mb master... && test_path_is_file .git/refs/heads/mb
46 +test_expect_success 'git branch mb main... should create a branch' '
47 + git branch mb main... && test_path_is_file .git/refs/heads/mb
48 '
49
50 test_expect_success 'git branch HEAD should fail' '
@@ -51,7 +52,7 @@ test_expect_success 'git branch HEAD should fail' '
52 '
53
54 cat >expect <<EOF
54 -$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
55 +$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from main
56 EOF
57 test_expect_success 'git branch --create-reflog d/e/f should create a branch and a log' '
58 GIT_COMMITTER_DATE="2005-05-26 23:30" \
@@ -110,7 +111,7 @@ test_expect_success 'git branch -m n/n n should work' '
111
112 test_expect_success 'git branch -m bbb should rename checked out branch' '
113 test_when_finished git branch -D bbb &&
113 - test_when_finished git checkout master &&
114 + test_when_finished git checkout main &&
115 git checkout -b aaa &&
116 git commit --allow-empty -m "a new commit" &&
117 git rev-parse aaa@{0} >expect &&
@@ -124,7 +125,7 @@ test_expect_success 'git branch -m bbb should rename checked out branch' '
125
126 test_expect_success 'renaming checked out branch works with d/f conflict' '
127 test_when_finished "git branch -D foo/bar || git branch -D foo" &&
127 - test_when_finished git checkout master &&
128 + test_when_finished git checkout main &&
129 git checkout -b foo &&
130 git branch -m foo/bar &&
131 git symbolic-ref HEAD >actual &&
@@ -178,14 +179,14 @@ test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD'
179 '
180
181 test_expect_success 'git branch -M should leave orphaned HEAD alone' '
181 - git init orphan &&
182 + git init -b main orphan &&
183 (
184 cd orphan &&
185 test_commit initial &&
186 git checkout --orphan lonely &&
187 grep lonely .git/HEAD &&
188 test_path_is_missing .git/refs/head/lonely &&
188 - git branch -M master mistress &&
189 + git branch -M main mistress &&
190 grep lonely .git/HEAD
191 )
192 '
@@ -201,7 +202,7 @@ test_expect_success 'resulting reflog can be shown by log -g' '
202 '
203
204 test_expect_success 'git branch -M baz bam should succeed when baz is checked out as linked working tree' '
204 - git checkout master &&
205 + git checkout main &&
206 git worktree add -b baz bazdir &&
207 git worktree add -f bazdir2 baz &&
208 git branch -M baz bam &&
@@ -224,18 +225,18 @@ test_expect_success 'git branch -M baz bam should succeed within a worktree in w
225 git worktree prune
226 '
227
227 -test_expect_success 'git branch -M master should work when master is checked out' '
228 - git checkout master &&
229 - git branch -M master
228 +test_expect_success 'git branch -M main should work when main is checked out' '
229 + git checkout main &&
230 + git branch -M main
231 '
232
232 -test_expect_success 'git branch -M master master should work when master is checked out' '
233 - git checkout master &&
234 - git branch -M master master
233 +test_expect_success 'git branch -M main main should work when main is checked out' '
234 + git checkout main &&
235 + git branch -M main main
236 '
237
237 -test_expect_success 'git branch -M topic topic should work when master is checked out' '
238 - git checkout master &&
238 +test_expect_success 'git branch -M topic topic should work when main is checked out' '
239 + git checkout main &&
240 git branch topic &&
241 git branch -M topic topic
242 '
@@ -289,11 +290,11 @@ test_expect_success 'deleting checked-out branch from repo that is a submodule'
290 test_expect_success 'bare main worktree has HEAD at branch deleted by secondary worktree' '
291 test_when_finished "rm -rf nonbare base secondary" &&
292
292 - git init nonbare &&
293 + git init -b main nonbare &&
294 test_commit -C nonbare x &&
295 git clone --bare nonbare bare &&
295 - git -C bare worktree add --detach ../secondary master &&
296 - git -C secondary branch -D master
296 + git -C bare worktree add --detach ../secondary main &&
297 + git -C secondary branch -D main
298 '
299
300 test_expect_success 'git branch --list -v with --abbrev' '
@@ -321,7 +322,7 @@ test_expect_success 'git branch --list -v with --abbrev' '
322
323 '
324
324 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch --column' '
325 +test_expect_success 'git branch --column' '
326 COLUMNS=81 git branch --column=column >actual &&
327 cat >expect <<\EOF &&
328 a/b/c bam foo l * main n o/p r
@@ -345,7 +346,7 @@ test_expect_success 'git branch --column with an extremely long branch name' '
346 j/k
347 l
348 m/m
348 -* master
349 +* main
350 mb
351 n
352 o/o
@@ -358,7 +359,7 @@ EOF
359 test_cmp expect actual
360 '
361
361 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch with column.*' '
362 +test_expect_success 'git branch with column.*' '
363 git config column.ui column &&
364 git config column.branch "dense" &&
365 COLUMNS=80 git branch >actual &&
@@ -375,7 +376,7 @@ test_expect_success 'git branch --column -v should fail' '
376 test_must_fail git branch --column -v
377 '
378
378 -test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch -v with column.ui ignored' '
379 +test_expect_success 'git branch -v with column.ui ignored' '
380 git config column.ui column &&
381 COLUMNS=80 git branch -v | cut -c -8 | sed "s/ *$//" >actual &&
382 git config --unset column.ui &&
@@ -388,7 +389,7 @@ test_expect_success PREPARE_FOR_MAIN_BRANCH 'git branch -v with column.ui ignore
389 j/k
390 l
391 m/m
391 -* master
392 +* main
393 mb
394 n
395 o/o
@@ -427,8 +428,8 @@ test_expect_success 'config information was renamed, too' '
428 '
429
430 test_expect_success 'git branch -m correctly renames multiple config sections' '
430 - test_when_finished "git checkout master" &&
431 - git checkout -b source master &&
431 + test_when_finished "git checkout main" &&
432 + git checkout -b source main &&
433
434 # Assert that a config file with multiple config sections has
435 # those sections preserved...
@@ -587,18 +588,18 @@ test_expect_success 'git branch -C c1 c2 should never touch HEAD' '
588 ! grep "$msg$" .git/logs/HEAD
589 '
590
590 -test_expect_success 'git branch -C master should work when master is checked out' '
591 - git checkout master &&
592 - git branch -C master
591 +test_expect_success 'git branch -C main should work when main is checked out' '
592 + git checkout main &&
593 + git branch -C main
594 '
595
595 -test_expect_success 'git branch -C master master should work when master is checked out' '
596 - git checkout master &&
597 - git branch -C master master
596 +test_expect_success 'git branch -C main main should work when main is checked out' '
597 + git checkout main &&
598 + git branch -C main main
599 '
600
600 -test_expect_success 'git branch -C main5 main5 should work when master is checked out' '
601 - git checkout master &&
601 +test_expect_success 'git branch -C main5 main5 should work when main is checked out' '
602 + git checkout main &&
603 git branch main5 &&
604 git branch -C main5 main5
605 '
@@ -620,8 +621,8 @@ test_expect_success 'git branch -C ab cd should overwrite existing config for cd
621 test_expect_success 'git branch -c correctly copies multiple config sections' '
622 FOO=1 &&
623 export FOO &&
623 - test_when_finished "git checkout master" &&
624 - git checkout -b source2 master &&
624 + test_when_finished "git checkout main" &&
625 + git checkout -b source2 main &&
626
627 # Assert that a config file with multiple config sections has
628 # those sections preserved...
@@ -711,10 +712,10 @@ test_expect_success 'deleting a self-referential symref' '
712 '
713
714 test_expect_success 'renaming a symref is not allowed' '
714 - git symbolic-ref refs/heads/topic refs/heads/master &&
715 + git symbolic-ref refs/heads/topic refs/heads/main &&
716 test_must_fail git branch -m topic new-topic &&
717 git symbolic-ref refs/heads/topic &&
717 - test_path_is_file .git/refs/heads/master &&
718 + test_path_is_file .git/refs/heads/main &&
719 test_path_is_missing .git/refs/heads/new-topic
720 '
721
@@ -728,27 +729,27 @@ test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for
729 test_expect_success 'test tracking setup via --track' '
730 git config remote.local.url . &&
731 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
731 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
732 - git branch --track my1 local/master &&
732 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
733 + git branch --track my1 local/main &&
734 test $(git config branch.my1.remote) = local &&
734 - test $(git config branch.my1.merge) = refs/heads/master
735 + test $(git config branch.my1.merge) = refs/heads/main
736 '
737
738 test_expect_success 'test tracking setup (non-wildcard, matching)' '
739 git config remote.local.url . &&
739 - git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
740 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
741 - git branch --track my4 local/master &&
740 + git config remote.local.fetch refs/heads/main:refs/remotes/local/main &&
741 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
742 + git branch --track my4 local/main &&
743 test $(git config branch.my4.remote) = local &&
743 - test $(git config branch.my4.merge) = refs/heads/master
744 + test $(git config branch.my4.merge) = refs/heads/main
745 '
746
747 test_expect_success 'tracking setup fails on non-matching refspec' '
748 git config remote.local.url . &&
749 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
749 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
750 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
751 git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
751 - test_must_fail git branch --track my5 local/master &&
752 + test_must_fail git branch --track my5 local/main &&
753 test_must_fail git config branch.my5.remote &&
754 test_must_fail git config branch.my5.merge
755 '
@@ -757,21 +758,21 @@ test_expect_success 'test tracking setup via config' '
758 git config branch.autosetupmerge true &&
759 git config remote.local.url . &&
760 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
760 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
761 - git branch my3 local/master &&
761 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
762 + git branch my3 local/main &&
763 test $(git config branch.my3.remote) = local &&
763 - test $(git config branch.my3.merge) = refs/heads/master
764 + test $(git config branch.my3.merge) = refs/heads/main
765 '
766
767 test_expect_success 'test overriding tracking setup via --no-track' '
768 git config branch.autosetupmerge true &&
769 git config remote.local.url . &&
770 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
770 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
771 - git branch --no-track my2 local/master &&
771 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
772 + git branch --no-track my2 local/main &&
773 git config branch.autosetupmerge false &&
774 ! test "$(git config branch.my2.remote)" = local &&
774 - ! test "$(git config branch.my2.merge)" = refs/heads/master
775 + ! test "$(git config branch.my2.merge)" = refs/heads/main
776 '
777
778 test_expect_success 'no tracking without .fetch entries' '
@@ -836,26 +837,26 @@ test_expect_success 'branch from tag w/--track causes failure' '
837
838 test_expect_success '--set-upstream-to fails on multiple branches' '
839 echo "fatal: too many arguments to set new upstream" >expect &&
839 - test_must_fail git branch --set-upstream-to master a b c 2>err &&
840 + test_must_fail git branch --set-upstream-to main a b c 2>err &&
841 test_i18ncmp expect err
842 '
843
844 test_expect_success '--set-upstream-to fails on detached HEAD' '
845 git checkout HEAD^{} &&
846 test_when_finished git checkout - &&
846 - echo "fatal: could not set upstream of HEAD to master when it does not point to any branch." >expect &&
847 - test_must_fail git branch --set-upstream-to master 2>err &&
847 + echo "fatal: could not set upstream of HEAD to main when it does not point to any branch." >expect &&
848 + test_must_fail git branch --set-upstream-to main 2>err &&
849 test_i18ncmp expect err
850 '
851
852 test_expect_success '--set-upstream-to fails on a missing dst branch' '
853 echo "fatal: branch '"'"'does-not-exist'"'"' does not exist" >expect &&
853 - test_must_fail git branch --set-upstream-to master does-not-exist 2>err &&
854 + test_must_fail git branch --set-upstream-to main does-not-exist 2>err &&
855 test_i18ncmp expect err
856 '
857
858 test_expect_success '--set-upstream-to fails on a missing src branch' '
858 - test_must_fail git branch --set-upstream-to does-not-exist master 2>err &&
859 + test_must_fail git branch --set-upstream-to does-not-exist main 2>err &&
860 test_i18ngrep "the requested upstream branch '"'"'does-not-exist'"'"' does not exist" err
861 '
862
@@ -874,20 +875,20 @@ test_expect_success '--set-upstream-to fails on locked config' '
875 '
876
877 test_expect_success 'use --set-upstream-to modify HEAD' '
877 - test_config branch.master.remote foo &&
878 - test_config branch.master.merge foo &&
878 + test_config branch.main.remote foo &&
879 + test_config branch.main.merge foo &&
880 git branch my12 &&
881 git branch --set-upstream-to my12 &&
881 - test "$(git config branch.master.remote)" = "." &&
882 - test "$(git config branch.master.merge)" = "refs/heads/my12"
882 + test "$(git config branch.main.remote)" = "." &&
883 + test "$(git config branch.main.merge)" = "refs/heads/my12"
884 '
885
886 test_expect_success 'use --set-upstream-to modify a particular branch' '
887 git branch my13 &&
887 - git branch --set-upstream-to master my13 &&
888 + git branch --set-upstream-to main my13 &&
889 test_when_finished "git branch --unset-upstream my13" &&
890 test "$(git config branch.my13.remote)" = "." &&
890 - test "$(git config branch.my13.merge)" = "refs/heads/master"
891 + test "$(git config branch.my13.merge)" = "refs/heads/main"
892 '
893
894 test_expect_success '--unset-upstream should fail if given a non-existent branch' '
@@ -906,14 +907,14 @@ test_expect_success '--unset-upstream should fail if config is locked' '
907
908 test_expect_success 'test --unset-upstream on HEAD' '
909 git branch my14 &&
909 - test_config branch.master.remote foo &&
910 - test_config branch.master.merge foo &&
910 + test_config branch.main.remote foo &&
911 + test_config branch.main.merge foo &&
912 git branch --set-upstream-to my14 &&
913 git branch --unset-upstream &&
913 - test_must_fail git config branch.master.remote &&
914 - test_must_fail git config branch.master.merge &&
914 + test_must_fail git config branch.main.remote &&
915 + test_must_fail git config branch.main.merge &&
916 # fail for a branch without upstream set
916 - echo "fatal: Branch '"'"'master'"'"' has no upstream information" >expect &&
917 + echo "fatal: Branch '"'"'main'"'"' has no upstream information" >expect &&
918 test_must_fail git branch --unset-upstream 2>err &&
919 test_i18ncmp expect err
920 '
@@ -934,14 +935,14 @@ test_expect_success '--unset-upstream should fail on detached HEAD' '
935
936 test_expect_success 'test --unset-upstream on a particular branch' '
937 git branch my15 &&
937 - git branch --set-upstream-to master my14 &&
938 + git branch --set-upstream-to main my14 &&
939 git branch --unset-upstream my14 &&
940 test_must_fail git config branch.my14.remote &&
941 test_must_fail git config branch.my14.merge
942 '
943
944 test_expect_success 'disabled option --set-upstream fails' '
944 - test_must_fail git branch --set-upstream origin/master
945 + test_must_fail git branch --set-upstream origin/main
946 '
947
948 test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
@@ -956,32 +957,32 @@ test_expect_success '--set-upstream-to notices an error to set branch as own ups
957
958 # Keep this test last, as it changes the current branch
959 cat >expect <<EOF
959 -$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
960 +$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from main
961 EOF
962 test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
963 GIT_COMMITTER_DATE="2005-05-26 23:30" \
963 - git checkout -b g/h/i -l master &&
964 + git checkout -b g/h/i -l main &&
965 test_path_is_file .git/refs/heads/g/h/i &&
966 test_path_is_file .git/logs/refs/heads/g/h/i &&
967 test_cmp expect .git/logs/refs/heads/g/h/i
968 '
969
970 test_expect_success 'checkout -b makes reflog by default' '
970 - git checkout master &&
971 + git checkout main &&
972 git config --unset core.logAllRefUpdates &&
973 git checkout -b alpha &&
974 git rev-parse --verify alpha@{0}
975 '
976
977 test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
977 - git checkout master &&
978 + git checkout main &&
979 git config core.logAllRefUpdates false &&
980 git checkout -b beta &&
981 test_must_fail git rev-parse --verify beta@{0}
982 '
983
984 test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
984 - git checkout master &&
985 + git checkout main &&
986 git checkout -lb gamma &&
987 git config --unset core.logAllRefUpdates &&
988 git rev-parse --verify gamma@{0}
@@ -990,10 +991,10 @@ test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates
991 test_expect_success 'avoid ambiguous track' '
992 git config branch.autosetupmerge true &&
993 git config remote.ambi1.url lalala &&
993 - git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
994 + git config remote.ambi1.fetch refs/heads/lalala:refs/heads/main &&
995 git config remote.ambi2.url lilili &&
995 - git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
996 - test_must_fail git branch all1 master &&
996 + git config remote.ambi2.fetch refs/heads/lilili:refs/heads/main &&
997 + test_must_fail git branch all1 main &&
998 test -z "$(git config branch.all1.merge)"
999 '
1000
@@ -1049,10 +1050,10 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '
1050 git config remote.local.url . &&
1051 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1052 git config branch.autosetuprebase local &&
1052 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1053 - git branch --track myr5 local/master &&
1053 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1054 + git branch --track myr5 local/main &&
1055 test "$(git config branch.myr5.remote)" = local &&
1055 - test "$(git config branch.myr5.merge)" = refs/heads/master &&
1056 + test "$(git config branch.myr5.merge)" = refs/heads/main &&
1057 ! test "$(git config branch.myr5.rebase)" = true
1058 '
1059
@@ -1060,10 +1061,10 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '
1061 git config remote.local.url . &&
1062 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1063 git config branch.autosetuprebase never &&
1063 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1064 - git branch --track myr6 local/master &&
1064 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1065 + git branch --track myr6 local/main &&
1066 test "$(git config branch.myr6.remote)" = local &&
1066 - test "$(git config branch.myr6.merge)" = refs/heads/master &&
1067 + test "$(git config branch.myr6.merge)" = refs/heads/main &&
1068 ! test "$(git config branch.myr6.rebase)" = true
1069 '
1070
@@ -1071,10 +1072,10 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '
1072 git config remote.local.url . &&
1073 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1074 git config branch.autosetuprebase remote &&
1074 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1075 - git branch --track myr7 local/master &&
1075 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1076 + git branch --track myr7 local/main &&
1077 test "$(git config branch.myr7.remote)" = local &&
1077 - test "$(git config branch.myr7.merge)" = refs/heads/master &&
1078 + test "$(git config branch.myr7.merge)" = refs/heads/main &&
1079 test "$(git config branch.myr7.rebase)" = true
1080 '
1081
@@ -1082,10 +1083,10 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '
1083 git config remote.local.url . &&
1084 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1085 git config branch.autosetuprebase remote &&
1085 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1086 - git branch --track myr8 local/master &&
1086 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1087 + git branch --track myr8 local/main &&
1088 test "$(git config branch.myr8.remote)" = local &&
1088 - test "$(git config branch.myr8.merge)" = refs/heads/master &&
1089 + test "$(git config branch.myr8.merge)" = refs/heads/main &&
1090 test "$(git config branch.myr8.rebase)" = true
1091 '
1092
@@ -1093,10 +1094,10 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
1094 git config --unset branch.autosetuprebase &&
1095 git config remote.local.url . &&
1096 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1096 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1097 - git branch --track myr9 local/master &&
1097 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1098 + git branch --track myr9 local/main &&
1099 test "$(git config branch.myr9.remote)" = local &&
1099 - test "$(git config branch.myr9.merge)" = refs/heads/master &&
1100 + test "$(git config branch.myr9.merge)" = refs/heads/main &&
1101 test "z$(git config branch.myr9.rebase)" = z
1102 '
1103
@@ -1114,7 +1115,7 @@ test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
1115 test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
1116 git config remote.local.url . &&
1117 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1117 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1118 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1119 git branch --no-track myr11 mybase2 &&
1120 test "z$(git config branch.myr11.remote)" = z &&
1121 test "z$(git config branch.myr11.merge)" = z &&
@@ -1124,8 +1125,8 @@ test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
1125 test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
1126 git config remote.local.url . &&
1127 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1127 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1128 - git branch --no-track myr12 local/master &&
1128 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1129 + git branch --no-track myr12 local/main &&
1130 test "z$(git config branch.myr12.remote)" = z &&
1131 test "z$(git config branch.myr12.merge)" = z &&
1132 test "z$(git config branch.myr12.rebase)" = z
@@ -1135,7 +1136,7 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '
1136 git config branch.autosetuprebase never &&
1137 git config remote.local.url . &&
1138 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1138 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1139 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1140 git branch --no-track myr13 mybase2 &&
1141 test "z$(git config branch.myr13.remote)" = z &&
1142 test "z$(git config branch.myr13.merge)" = z &&
@@ -1146,7 +1147,7 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '
1147 git config branch.autosetuprebase local &&
1148 git config remote.local.url . &&
1149 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1149 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1150 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1151 git branch --no-track myr14 mybase2 &&
1152 test "z$(git config branch.myr14.remote)" = z &&
1153 test "z$(git config branch.myr14.merge)" = z &&
@@ -1157,7 +1158,7 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '
1158 git config branch.autosetuprebase remote &&
1159 git config remote.local.url . &&
1160 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1160 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1161 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1162 git branch --no-track myr15 mybase2 &&
1163 test "z$(git config branch.myr15.remote)" = z &&
1164 test "z$(git config branch.myr15.merge)" = z &&
@@ -1168,7 +1169,7 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '
1169 git config branch.autosetuprebase always &&
1170 git config remote.local.url . &&
1171 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1171 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1172 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1173 git branch --no-track myr16 mybase2 &&
1174 test "z$(git config branch.myr16.remote)" = z &&
1175 test "z$(git config branch.myr16.merge)" = z &&
@@ -1179,8 +1180,8 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '
1180 git config branch.autosetuprebase never &&
1181 git config remote.local.url . &&
1182 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1182 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1183 - git branch --no-track myr17 local/master &&
1183 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1184 + git branch --no-track myr17 local/main &&
1185 test "z$(git config branch.myr17.remote)" = z &&
1186 test "z$(git config branch.myr17.merge)" = z &&
1187 test "z$(git config branch.myr17.rebase)" = z
@@ -1190,8 +1191,8 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '
1191 git config branch.autosetuprebase local &&
1192 git config remote.local.url . &&
1193 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1193 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1194 - git branch --no-track myr18 local/master &&
1194 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1195 + git branch --no-track myr18 local/main &&
1196 test "z$(git config branch.myr18.remote)" = z &&
1197 test "z$(git config branch.myr18.merge)" = z &&
1198 test "z$(git config branch.myr18.rebase)" = z
@@ -1201,8 +1202,8 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '
1202 git config branch.autosetuprebase remote &&
1203 git config remote.local.url . &&
1204 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1204 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1205 - git branch --no-track myr19 local/master &&
1205 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1206 + git branch --no-track myr19 local/main &&
1207 test "z$(git config branch.myr19.remote)" = z &&
1208 test "z$(git config branch.myr19.merge)" = z &&
1209 test "z$(git config branch.myr19.rebase)" = z
@@ -1212,8 +1213,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
1213 git config branch.autosetuprebase always &&
1214 git config remote.local.url . &&
1215 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
1215 - (git show-ref -q refs/remotes/local/master || git fetch local) &&
1216 - git branch --no-track myr20 local/master &&
1216 + (git show-ref -q refs/remotes/local/main || git fetch local) &&
1217 + git branch --no-track myr20 local/main &&
1218 test "z$(git config branch.myr20.remote)" = z &&
1219 test "z$(git config branch.myr20.merge)" = z &&
1220 test "z$(git config branch.myr20.rebase)" = z
@@ -1221,7 +1222,7 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
1222
1223 test_expect_success 'autosetuprebase always on detached HEAD' '
1224 git config branch.autosetupmerge always &&
1224 - test_when_finished git checkout master &&
1225 + test_when_finished git checkout main &&
1226 git checkout HEAD^0 &&
1227 git branch my11 &&
1228 test -z "$(git config branch.my11.remote)" &&
@@ -1249,18 +1250,18 @@ test_expect_success 'attempt to delete a branch without base and unmerged to HEA
1250 test_expect_success 'attempt to delete a branch merged to its base' '
1251 # we are on my9 which is the initial commit; traditionally
1252 # we would not have allowed deleting my8 that is not merged
1252 - # to my9, but it is set to track master that already has my8
1253 - git config branch.my8.merge refs/heads/master &&
1253 + # to my9, but it is set to track main that already has my8
1254 + git config branch.my8.merge refs/heads/main &&
1255 git branch -d my8
1256 '
1257
1258 test_expect_success 'attempt to delete a branch merged to its base' '
1258 - git checkout master &&
1259 + git checkout main &&
1260 echo Third >>A &&
1261 git commit -m "Third commit" A &&
1262 git branch -t my10 my9 &&
1263 git branch -f my10 HEAD^ &&
1263 - # we are on master which is at the third commit, and my10
1264 + # we are on main which is at the third commit, and my10
1265 # is behind us, so traditionally we would have allowed deleting
1266 # it; but my10 is set to track my9 that is further behind.
1267 test_must_fail git branch -d my10
@@ -1287,7 +1288,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '
1288 '
1289
1290 test_expect_success 'refuse --edit-description on unborn branch for now' '
1290 - test_when_finished "git checkout master" &&
1291 + test_when_finished "git checkout main" &&
1292 write_script editor <<-\EOF &&
1293 echo "New contents" >"$1"
1294 EOF
@@ -1301,18 +1302,18 @@ test_expect_success '--merged catches invalid object names' '
1302
1303 test_expect_success '--list during rebase' '
1304 test_when_finished "reset_rebase" &&
1304 - git checkout master &&
1305 + git checkout main &&
1306 FAKE_LINES="1 edit 2" &&
1307 export FAKE_LINES &&
1308 set_fake_editor &&
1309 git rebase -i HEAD~2 &&
1310 git branch --list >actual &&
1310 - test_i18ngrep "rebasing master" actual
1311 + test_i18ngrep "rebasing main" actual
1312 '
1313
1314 test_expect_success '--list during rebase from detached HEAD' '
1314 - test_when_finished "reset_rebase && git checkout master" &&
1315 - git checkout master^0 &&
1315 + test_when_finished "reset_rebase && git checkout main" &&
1316 + git checkout main^0 &&
1317 oid=$(git rev-parse --short HEAD) &&
1318 FAKE_LINES="1 edit 2" &&
1319 export FAKE_LINES &&
@@ -1324,17 +1325,17 @@ test_expect_success '--list during rebase from detached HEAD' '
1325
1326 test_expect_success 'tracking with unexpected .fetch refspec' '
1327 rm -rf a b c d &&
1327 - git init a &&
1328 + git init -b main a &&
1329 (
1330 cd a &&
1331 test_commit a
1332 ) &&
1332 - git init b &&
1333 + git init -b main b &&
1334 (
1335 cd b &&
1336 test_commit b
1337 ) &&
1337 - git init c &&
1338 + git init -b main c &&
1339 (
1340 cd c &&
1341 test_commit c &&
@@ -1342,23 +1343,23 @@ test_expect_success 'tracking with unexpected .fetch refspec' '
1343 git remote add b ../b &&
1344 git fetch --all
1345 ) &&
1345 - git init d &&
1346 + git init -b main d &&
1347 (
1348 cd d &&
1349 git remote add c ../c &&
1350 git config remote.c.fetch "+refs/remotes/*:refs/remotes/*" &&
1351 git fetch c &&
1351 - git branch --track local/a/master remotes/a/master &&
1352 - test "$(git config branch.local/a/master.remote)" = "c" &&
1353 - test "$(git config branch.local/a/master.merge)" = "refs/remotes/a/master" &&
1352 + git branch --track local/a/main remotes/a/main &&
1353 + test "$(git config branch.local/a/main.remote)" = "c" &&
1354 + test "$(git config branch.local/a/main.merge)" = "refs/remotes/a/main" &&
1355 git rev-parse --verify a >expect &&
1355 - git rev-parse --verify local/a/master >actual &&
1356 + git rev-parse --verify local/a/main >actual &&
1357 test_cmp expect actual
1358 )
1359 '
1360
1361 test_expect_success 'configured committerdate sort' '
1361 - git init sort &&
1362 + git init -b main sort &&
1363 (
1364 cd sort &&
1365 git config branch.sort committerdate &&
@@ -1371,7 +1372,7 @@ test_expect_success 'configured committerdate sort' '
1372 test_commit b &&
1373 git branch >actual &&
1374 cat >expect <<-\EOF &&
1374 - master
1375 + main
1376 a
1377 c
1378 * b
@@ -1389,7 +1390,7 @@ test_expect_success 'option override configured sort' '
1390 a
1391 * b
1392 c
1392 - master
1393 + main
1394 EOF
1395 test_cmp expect actual
1396 )