t3203: complete the transition to using the branch name main

In 66713e84e7 (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>
This commit is contained in:
Johannes Schindelin
2020-12-17 01:07:03 +00:00
committed by Junio C Hamano
parent 94287e788b
commit 1eee0a42f9

View File

@ -8,6 +8,7 @@ test_expect_success 'make commits' '
echo content >file && echo content >file &&
git add file && git add file &&
git commit -m one && git commit -m one &&
git branch -M main &&
echo content >>file && echo content >>file &&
git commit -a -m two git commit -a -m two
' '
@ -26,7 +27,7 @@ test_expect_success 'make remote branches' '
cat >expect <<'EOF' cat >expect <<'EOF'
branch-one branch-one
branch-two branch-two
* master * main
EOF EOF
test_expect_success 'git branch shows local branches' ' test_expect_success 'git branch shows local branches' '
git branch >actual && git branch >actual &&
@ -60,7 +61,7 @@ test_expect_success 'git branch -r shows remote branches' '
cat >expect <<'EOF' cat >expect <<'EOF'
branch-one branch-one
branch-two branch-two
* master * main
remotes/origin/HEAD -> origin/branch-one remotes/origin/HEAD -> origin/branch-one
remotes/origin/branch-one remotes/origin/branch-one
remotes/origin/branch-two remotes/origin/branch-two
@ -152,7 +153,7 @@ test_expect_success 'git branch shows detached HEAD properly' '
* (HEAD detached at $(git rev-parse --short HEAD^0)) * (HEAD detached at $(git rev-parse --short HEAD^0))
branch-one branch-one
branch-two branch-two
master main
EOF EOF
git checkout HEAD^0 && git checkout HEAD^0 &&
git branch >actual && git branch >actual &&
@ -160,12 +161,12 @@ EOF
' '
test_expect_success 'git branch shows detached HEAD properly after checkout --detach' ' test_expect_success 'git branch shows detached HEAD properly after checkout --detach' '
git checkout master && git checkout main &&
cat >expect <<EOF && cat >expect <<EOF &&
* (HEAD detached at $(git rev-parse --short HEAD^0)) * (HEAD detached at $(git rev-parse --short HEAD^0))
branch-one branch-one
branch-two branch-two
master main
EOF EOF
git checkout --detach && git checkout --detach &&
git branch >actual && git branch >actual &&
@ -177,7 +178,7 @@ test_expect_success 'git branch shows detached HEAD properly after moving' '
* (HEAD detached from $(git rev-parse --short HEAD)) * (HEAD detached from $(git rev-parse --short HEAD))
branch-one branch-one
branch-two branch-two
master main
EOF EOF
git reset --hard HEAD^1 && git reset --hard HEAD^1 &&
git branch >actual && git branch >actual &&
@ -189,9 +190,9 @@ test_expect_success 'git branch shows detached HEAD properly from tag' '
* (HEAD detached at fromtag) * (HEAD detached at fromtag)
branch-one branch-one
branch-two branch-two
master main
EOF EOF
git tag fromtag master && git tag fromtag main &&
git checkout fromtag && git checkout fromtag &&
git branch >actual && git branch >actual &&
test_i18ncmp expect actual test_i18ncmp expect actual
@ -202,7 +203,7 @@ test_expect_success 'git branch shows detached HEAD properly after moving from t
* (HEAD detached from fromtag) * (HEAD detached from fromtag)
branch-one branch-one
branch-two branch-two
master main
EOF EOF
git reset --hard HEAD^1 && git reset --hard HEAD^1 &&
git branch >actual && git branch >actual &&
@ -214,7 +215,7 @@ test_expect_success 'git branch `--sort` option' '
* (HEAD detached from fromtag) * (HEAD detached from fromtag)
branch-two branch-two
branch-one branch-one
master main
EOF EOF
git branch --sort=objectsize >actual && git branch --sort=objectsize >actual &&
test_i18ncmp expect actual test_i18ncmp expect actual
@ -223,7 +224,7 @@ test_expect_success 'git branch `--sort` option' '
test_expect_success 'git branch --points-at option' ' test_expect_success 'git branch --points-at option' '
cat >expect <<-\EOF && cat >expect <<-\EOF &&
branch-one branch-one
master main
EOF EOF
git branch --points-at=branch-one >actual && git branch --points-at=branch-one >actual &&
test_cmp expect actual test_cmp expect actual
@ -251,7 +252,7 @@ test_expect_success 'local-branch symrefs shortened properly' '
test_expect_success 'sort branches, ignore case' ' test_expect_success 'sort branches, ignore case' '
( (
git init sort-icase && git init -b main sort-icase &&
cd sort-icase && cd sort-icase &&
test_commit initial && test_commit initial &&
git branch branch-one && git branch branch-one &&
@ -260,14 +261,14 @@ test_expect_success 'sort branches, ignore case' '
cat >expected <<-\EOF && cat >expected <<-\EOF &&
BRANCH-two BRANCH-two
branch-one branch-one
master main
EOF EOF
test_cmp expected actual && test_cmp expected actual &&
git branch --list -i | awk "{print \$NF}" >actual && git branch --list -i | awk "{print \$NF}" >actual &&
cat >expected <<-\EOF && cat >expected <<-\EOF &&
branch-one branch-one
BRANCH-two BRANCH-two
master main
EOF EOF
test_cmp expected actual test_cmp expected actual
) )
@ -279,7 +280,7 @@ test_expect_success 'git branch --format option' '
Refname is refs/heads/ambiguous Refname is refs/heads/ambiguous
Refname is refs/heads/branch-one Refname is refs/heads/branch-one
Refname is refs/heads/branch-two Refname is refs/heads/branch-two
Refname is refs/heads/master Refname is refs/heads/main
Refname is refs/heads/ref-to-branch Refname is refs/heads/ref-to-branch
Refname is refs/heads/ref-to-remote Refname is refs/heads/ref-to-remote
EOF EOF
@ -293,7 +294,7 @@ test_expect_success 'worktree colors correct' '
ambiguous<RESET> ambiguous<RESET>
branch-one<RESET> branch-one<RESET>
+ <CYAN>branch-two<RESET> + <CYAN>branch-two<RESET>
master<RESET> main<RESET>
ref-to-branch<RESET> -> branch-one ref-to-branch<RESET> -> branch-one
ref-to-remote<RESET> -> origin/branch-one ref-to-remote<RESET> -> origin/branch-one
EOF EOF
@ -306,9 +307,9 @@ test_expect_success 'worktree colors correct' '
' '
test_expect_success "set up color tests" ' test_expect_success "set up color tests" '
echo "<RED>master<RESET>" >expect.color && echo "<RED>main<RESET>" >expect.color &&
echo "master" >expect.bare && echo "main" >expect.bare &&
color_args="--format=%(color:red)%(refname:short) --list master" color_args="--format=%(color:red)%(refname:short) --list main"
' '
test_expect_success '%(color) omitted without tty' ' test_expect_success '%(color) omitted without tty' '
@ -329,9 +330,9 @@ test_expect_success '--color overrides auto-color' '
test_cmp expect.color actual test_cmp expect.color actual
' '
test_expect_success PREPARE_FOR_MAIN_BRANCH 'verbose output lists worktree path' ' test_expect_success 'verbose output lists worktree path' '
one=$(git rev-parse --short HEAD) && one=$(git rev-parse --short HEAD) &&
two=$(git rev-parse --short master) && two=$(git rev-parse --short main) &&
cat >expect <<-EOF && cat >expect <<-EOF &&
* (HEAD detached from fromtag) $one one * (HEAD detached from fromtag) $one one
ambiguous $one one ambiguous $one one