git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 04/11] t3203: complete the transition to using the branch name `main`

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 17, 2020, 01:07 UTC
Message-ID
<b8e7b6ed428b8ebd4ae7625cf818ed523535f6fd.1608167230.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.816.git.1608167230.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 t/t3203-branch-output.sh | 43 ++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index d65586541d2..b945faf4702 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -8,6 +8,7 @@ test_expect_success 'make commits' '
 	echo content >file &&
 	git add file &&
 	git commit -m one &&
+	git branch -M main &&
 	echo content >>file &&
 	git commit -a -m two
 '
@@ -26,7 +27,7 @@ test_expect_success 'make remote branches' '
 cat >expect <<'EOF'
   branch-one
   branch-two
-* master
+* main
 EOF
 test_expect_success 'git branch shows local branches' '
 	git branch >actual &&
@@ -60,7 +61,7 @@ test_expect_success 'git branch -r shows remote branches' '
 cat >expect <<'EOF'
   branch-one
   branch-two
-* master
+* main
   remotes/origin/HEAD -> origin/branch-one
   remotes/origin/branch-one
   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))
   branch-one
   branch-two
-  master
+  main
 EOF
 	git checkout HEAD^0 &&
 	git branch >actual &&
@@ -160,12 +161,12 @@ EOF
 '
 
 test_expect_success 'git branch shows detached HEAD properly after checkout --detach' '
-	git checkout master &&
+	git checkout main &&
 	cat >expect <<EOF &&
 * (HEAD detached at $(git rev-parse --short HEAD^0))
   branch-one
   branch-two
-  master
+  main
 EOF
 	git checkout --detach &&
 	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))
   branch-one
   branch-two
-  master
+  main
 EOF
 	git reset --hard HEAD^1 &&
 	git branch >actual &&
@@ -189,9 +190,9 @@ test_expect_success 'git branch shows detached HEAD properly from tag' '
 * (HEAD detached at fromtag)
   branch-one
   branch-two
-  master
+  main
 EOF
-	git tag fromtag master &&
+	git tag fromtag main &&
 	git checkout fromtag &&
 	git branch >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)
   branch-one
   branch-two
-  master
+  main
 EOF
 	git reset --hard HEAD^1 &&
 	git branch >actual &&
@@ -214,7 +215,7 @@ test_expect_success 'git branch `--sort` option' '
 	* (HEAD detached from fromtag)
 	  branch-two
 	  branch-one
-	  master
+	  main
 	EOF
 	git branch --sort=objectsize >actual &&
 	test_i18ncmp expect actual
@@ -223,7 +224,7 @@ test_expect_success 'git branch `--sort` option' '
 test_expect_success 'git branch --points-at option' '
 	cat >expect <<-\EOF &&
 	  branch-one
-	  master
+	  main
 	EOF
 	git branch --points-at=branch-one >actual &&
 	test_cmp expect actual
@@ -251,7 +252,7 @@ test_expect_success 'local-branch symrefs shortened properly' '
 
 test_expect_success 'sort branches, ignore case' '
 	(
-		git init sort-icase &&
+		git init -b main sort-icase &&
 		cd sort-icase &&
 		test_commit initial &&
 		git branch branch-one &&
@@ -260,14 +261,14 @@ test_expect_success 'sort branches, ignore case' '
 		cat >expected <<-\EOF &&
 		BRANCH-two
 		branch-one
-		master
+		main
 		EOF
 		test_cmp expected actual &&
 		git branch --list -i | awk "{print \$NF}" >actual &&
 		cat >expected <<-\EOF &&
 		branch-one
 		BRANCH-two
-		master
+		main
 		EOF
 		test_cmp expected actual
 	)
@@ -279,7 +280,7 @@ test_expect_success 'git branch --format option' '
 	Refname is refs/heads/ambiguous
 	Refname is refs/heads/branch-one
 	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-remote
 	EOF
@@ -293,7 +294,7 @@ test_expect_success 'worktree colors correct' '
 	  ambiguous<RESET>
 	  branch-one<RESET>
 	+ <CYAN>branch-two<RESET>
-	  master<RESET>
+	  main<RESET>
 	  ref-to-branch<RESET> -> branch-one
 	  ref-to-remote<RESET> -> origin/branch-one
 	EOF
@@ -306,9 +307,9 @@ test_expect_success 'worktree colors correct' '
 '
 
 test_expect_success "set up color tests" '
-	echo "<RED>master<RESET>" >expect.color &&
-	echo "master" >expect.bare &&
-	color_args="--format=%(color:red)%(refname:short) --list master"
+	echo "<RED>main<RESET>" >expect.color &&
+	echo "main" >expect.bare &&
+	color_args="--format=%(color:red)%(refname:short) --list main"
 '
 
 test_expect_success '%(color) omitted without tty' '
@@ -329,9 +330,9 @@ test_expect_success '--color overrides auto-color' '
 	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) &&
-	two=$(git rev-parse --short master) &&
+	two=$(git rev-parse --short main) &&
 	cat >expect <<-EOF &&
 	* (HEAD detached from fromtag) $one one
 	  ambiguous                    $one one
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 6 of 13 in “Drop the PREPARE_FOR_MAIN_BRANCH prereq”
  1. 00/11 Drop the PREPARE_FOR_MAIN_BRANCH prereqJohannes Schindelin via GitGitGadget, Dec 17, 2020
  2. 01/11 t1400: use `main` as initial branch nameJohannes Schindelin via GitGitGadget, Dec 17, 2020
  3. 02/11 t3200: finish transitioning to the initial branch name `main`Johannes Schindelin via GitGitGadget, Dec 17, 2020
  4. 03/11 t3201: finalize transitioning to using the branch name `main`Johannes Schindelin via GitGitGadget, Dec 17, 2020
  5. 06/11 t5505: finalize transitioning to using the branch name `main`Johannes Schindelin via GitGitGadget, Dec 17, 2020
  6. 04/11 t3203: complete the transition to using the branch name `main`Johannes Schindelin via GitGitGadget, Dec 17, 2020
  7. 11/11 tests: drop the `PREPARE_FOR_MAIN_BRANCH` prereqJohannes Schindelin via GitGitGadget, Dec 17, 2020
  8. 09/11 t6302: use `main` as initial branch nameJohannes Schindelin via GitGitGadget, Dec 17, 2020
  9. 05/11 t3205: finalize transitioning to using the branch name `main`Johannes Schindelin via GitGitGadget, Dec 17, 2020
  10. 08/11 t5703: use `main` as initial branch nameJohannes Schindelin via GitGitGadget, Dec 17, 2020
  11. 10/11 t9902: use `main` as initial branch nameJohannes Schindelin via GitGitGadget, Dec 17, 2020
  12. 07/11 t5510: use `main` as initial branch nameJohannes Schindelin via GitGitGadget, Dec 17, 2020
  13. Junio C HamanoDec 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.