{"thread":{"id":"54773","subject":"[PATCH] t6300: avoid using the default name of the initial branch","startedAt":"2020-12-06T13:17:15Z","lastAt":"2020-12-06T13:17:15Z","messageCount":1,"participants":["Johannes Schindelin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"411560","messageId":"pull.810.git.1607260559712.gitgitgadget@gmail.com","threadId":"54773","inReplyTo":null,"subject":"[PATCH] t6300: avoid using the default name of the initial branch","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-12-06T13:15:59Z","receivedAt":"2020-12-06T13:17:15Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nOur test suite currently only passes when `git init` uses the name\n`master` for the initial branch. This would stop us from changing the\ndefault branch name.\n\nLet's adjust t6300 so that it does not rely on any specific default\nbranch name. This trick is done by (force-)renaming the initial branch\nto the name `main` in the `setup` and the `:remotename and :remoteref`\ntest cases, and then replacing all mentions of `master` and `MASTER`\nwith `main` and `MAIN`, respectively.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    t6300: avoid using the default name of the initial branch\n    \n    This patch targets master (there is one other topic in flight touching\n    t6300: dr/push-remoteref-fix, but it does not conflict with this patch).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-810%2Fdscho%2Ft6300-and-the-default-branch-name-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-810/dscho/t6300-and-the-default-branch-name-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/810\n\n t/t6300-for-each-ref.sh | 178 ++++++++++++++++++++--------------------\n 1 file changed, 90 insertions(+), 88 deletions(-)\n\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex b3590231899..810cdbb6f88 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -28,12 +28,13 @@ test_expect_success setup '\n \techo \"Using $datestamp\" > one &&\n \tgit add one &&\n \tgit commit -m \"Initial\" &&\n+\tgit branch -M main &&\n \tsetdate_and_increment &&\n \tgit tag -a -m \"Tagging at $datestamp\" testtag &&\n-\tgit update-ref refs/remotes/origin/master master &&\n+\tgit update-ref refs/remotes/origin/main main &&\n \tgit remote add origin nowhere &&\n-\tgit config branch.master.remote origin &&\n-\tgit config branch.master.merge refs/heads/master &&\n+\tgit config branch.main.remote origin &&\n+\tgit config branch.main.merge refs/heads/main &&\n \tgit remote add myfork elsewhere &&\n \tgit config remote.pushdefault myfork &&\n \tgit config push.default current\n@@ -41,7 +42,7 @@ test_expect_success setup '\n \n test_atom() {\n \tcase \"$1\" in\n-\t\thead) ref=refs/heads/master ;;\n+\t\thead) ref=refs/heads/main ;;\n \t\t tag) ref=refs/tags/testtag ;;\n \t\t sym) ref=refs/heads/sym ;;\n \t\t   *) ref=$1 ;;\n@@ -76,49 +77,49 @@ test_atom() {\n hexlen=$(test_oid hexsz)\n disklen=$(test_oid disklen)\n \n-test_atom head refname refs/heads/master\n-test_atom head refname: refs/heads/master\n-test_atom head refname:short master\n-test_atom head refname:lstrip=1 heads/master\n-test_atom head refname:lstrip=2 master\n-test_atom head refname:lstrip=-1 master\n-test_atom head refname:lstrip=-2 heads/master\n+test_atom head refname refs/heads/main\n+test_atom head refname: refs/heads/main\n+test_atom head refname:short main\n+test_atom head refname:lstrip=1 heads/main\n+test_atom head refname:lstrip=2 main\n+test_atom head refname:lstrip=-1 main\n+test_atom head refname:lstrip=-2 heads/main\n test_atom head refname:rstrip=1 refs/heads\n test_atom head refname:rstrip=2 refs\n test_atom head refname:rstrip=-1 refs\n test_atom head refname:rstrip=-2 refs/heads\n-test_atom head refname:strip=1 heads/master\n-test_atom head refname:strip=2 master\n-test_atom head refname:strip=-1 master\n-test_atom head refname:strip=-2 heads/master\n-test_atom head upstream refs/remotes/origin/master\n-test_atom head upstream:short origin/master\n-test_atom head upstream:lstrip=2 origin/master\n-test_atom head upstream:lstrip=-2 origin/master\n+test_atom head refname:strip=1 heads/main\n+test_atom head refname:strip=2 main\n+test_atom head refname:strip=-1 main\n+test_atom head refname:strip=-2 heads/main\n+test_atom head upstream refs/remotes/origin/main\n+test_atom head upstream:short origin/main\n+test_atom head upstream:lstrip=2 origin/main\n+test_atom head upstream:lstrip=-2 origin/main\n test_atom head upstream:rstrip=2 refs/remotes\n test_atom head upstream:rstrip=-2 refs/remotes\n-test_atom head upstream:strip=2 origin/master\n-test_atom head upstream:strip=-2 origin/master\n-test_atom head push refs/remotes/myfork/master\n-test_atom head push:short myfork/master\n-test_atom head push:lstrip=1 remotes/myfork/master\n-test_atom head push:lstrip=-1 master\n+test_atom head upstream:strip=2 origin/main\n+test_atom head upstream:strip=-2 origin/main\n+test_atom head push refs/remotes/myfork/main\n+test_atom head push:short myfork/main\n+test_atom head push:lstrip=1 remotes/myfork/main\n+test_atom head push:lstrip=-1 main\n test_atom head push:rstrip=1 refs/remotes/myfork\n test_atom head push:rstrip=-1 refs\n-test_atom head push:strip=1 remotes/myfork/master\n-test_atom head push:strip=-1 master\n+test_atom head push:strip=1 remotes/myfork/main\n+test_atom head push:strip=-1 main\n test_atom head objecttype commit\n test_atom head objectsize $((131 + hexlen))\n test_atom head objectsize:disk $disklen\n test_atom head deltabase $ZERO_OID\n-test_atom head objectname $(git rev-parse refs/heads/master)\n-test_atom head objectname:short $(git rev-parse --short refs/heads/master)\n-test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)\n-test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/master)\n-test_atom head tree $(git rev-parse refs/heads/master^{tree})\n-test_atom head tree:short $(git rev-parse --short refs/heads/master^{tree})\n-test_atom head tree:short=1 $(git rev-parse --short=1 refs/heads/master^{tree})\n-test_atom head tree:short=10 $(git rev-parse --short=10 refs/heads/master^{tree})\n+test_atom head objectname $(git rev-parse refs/heads/main)\n+test_atom head objectname:short $(git rev-parse --short refs/heads/main)\n+test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/main)\n+test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/main)\n+test_atom head tree $(git rev-parse refs/heads/main^{tree})\n+test_atom head tree:short $(git rev-parse --short refs/heads/main^{tree})\n+test_atom head tree:short=1 $(git rev-parse --short=1 refs/heads/main^{tree})\n+test_atom head tree:short=10 $(git rev-parse --short=10 refs/heads/main^{tree})\n test_atom head parent ''\n test_atom head parent:short ''\n test_atom head parent:short=1 ''\n@@ -171,8 +172,8 @@ test_atom tag deltabase $ZERO_OID\n test_atom tag '*deltabase' $ZERO_OID\n test_atom tag objectname $(git rev-parse refs/tags/testtag)\n test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)\n-test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)\n-test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/master)\n+test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/main)\n+test_atom head objectname:short=10 $(git rev-parse --short=10 refs/heads/main)\n test_atom tag tree ''\n test_atom tag tree:short ''\n test_atom tag tree:short=1 ''\n@@ -253,7 +254,7 @@ test_date () {\n \tauthor_date=$3 &&\n \ttagger_date=$4 &&\n \tcat >expected <<-EOF &&\n-\t'refs/heads/master' '$committer_date' '$author_date'\n+\t'refs/heads/main' '$committer_date' '$author_date'\n \t'refs/tags/testtag' '$tagger_date'\n \tEOF\n \t(\n@@ -375,8 +376,8 @@ test_expect_success 'exercise strftime with odd fields' '\n '\n \n cat >expected <<\\EOF\n-refs/heads/master\n-refs/remotes/origin/master\n+refs/heads/main\n+refs/remotes/origin/main\n refs/tags/testtag\n EOF\n \n@@ -388,8 +389,8 @@ test_expect_success 'Verify ascending sort' '\n \n cat >expected <<\\EOF\n refs/tags/testtag\n-refs/remotes/origin/master\n-refs/heads/master\n+refs/remotes/origin/main\n+refs/heads/main\n EOF\n \n test_expect_success 'Verify descending sort' '\n@@ -424,8 +425,8 @@ test_expect_success 'exercise glob patterns with prefixes' '\n '\n \n cat >expected <<\\EOF\n-'refs/heads/master'\n-'refs/remotes/origin/master'\n+'refs/heads/main'\n+'refs/remotes/origin/main'\n 'refs/tags/testtag'\n EOF\n \n@@ -445,8 +446,8 @@ test_expect_success 'Quoting style: python' '\n '\n \n cat >expected <<\\EOF\n-\"refs/heads/master\"\n-\"refs/remotes/origin/master\"\n+\"refs/heads/main\"\n+\"refs/remotes/origin/main\"\n \"refs/tags/testtag\"\n EOF\n \n@@ -473,8 +474,8 @@ test_atom head upstream:nobracket,track 'ahead 1'\n \n test_expect_success 'setup for push:track[short]' '\n \ttest_commit third &&\n-\tgit update-ref refs/remotes/myfork/master master &&\n-\tgit reset master~1\n+\tgit update-ref refs/remotes/myfork/main main &&\n+\tgit reset main~1\n '\n \n test_atom head push:track '[behind 1]'\n@@ -490,8 +491,8 @@ test_expect_success 'Check that :track[short] works when upstream is invalid' '\n \t[gone]\n \n \tEOF\n-\ttest_when_finished \"git config branch.master.merge refs/heads/master\" &&\n-\tgit config branch.master.merge refs/heads/does-not-exist &&\n+\ttest_when_finished \"git config branch.main.merge refs/heads/main\" &&\n+\tgit config branch.main.merge refs/heads/does-not-exist &&\n \tgit for-each-ref \\\n \t\t--format=\"%(upstream:track)$LF%(upstream:trackshort)\" \\\n \t\trefs/heads >actual &&\n@@ -504,9 +505,9 @@ test_expect_success 'Check for invalid refname format' '\n \n test_expect_success 'set up color tests' '\n \tcat >expected.color <<-EOF &&\n-\t$(git rev-parse --short refs/heads/master) <GREEN>master<RESET>\n-\t$(git rev-parse --short refs/remotes/myfork/master) <GREEN>myfork/master<RESET>\n-\t$(git rev-parse --short refs/remotes/origin/master) <GREEN>origin/master<RESET>\n+\t$(git rev-parse --short refs/heads/main) <GREEN>main<RESET>\n+\t$(git rev-parse --short refs/remotes/myfork/main) <GREEN>myfork/main<RESET>\n+\t$(git rev-parse --short refs/remotes/origin/main) <GREEN>origin/main<RESET>\n \t$(git rev-parse --short refs/tags/testtag) <GREEN>testtag<RESET>\n \t$(git rev-parse --short refs/tags/third) <GREEN>third<RESET>\n \t$(git rev-parse --short refs/tags/two) <GREEN>two<RESET>\n@@ -538,8 +539,8 @@ test_expect_success 'color.ui=always does not override tty check' '\n '\n \n cat >expected <<\\EOF\n-heads/master\n-tags/master\n+heads/main\n+tags/main\n EOF\n \n test_expect_success 'Check ambiguous head and tag refs (strict)' '\n@@ -549,19 +550,19 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '\n \tgit add one &&\n \tgit commit -m \"Branch\" &&\n \tsetdate_and_increment &&\n-\tgit tag -m \"Tagging at $datestamp\" master &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n+\tgit tag -m \"Tagging at $datestamp\" main &&\n+\tgit for-each-ref --format \"%(refname:short)\" refs/heads/main refs/tags/main >actual &&\n \ttest_cmp expected actual\n '\n \n cat >expected <<\\EOF\n-heads/master\n-master\n+heads/main\n+main\n EOF\n \n test_expect_success 'Check ambiguous head and tag refs (loose)' '\n \tgit config --bool core.warnambiguousrefs false &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n+\tgit for-each-ref --format \"%(refname:short)\" refs/heads/main refs/tags/main >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -571,7 +572,7 @@ ambiguous\n EOF\n \n test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n-\tgit checkout master &&\n+\tgit checkout main &&\n \tgit tag ambiguous testtag^0 &&\n \tgit branch ambiguous testtag^0 &&\n \tgit for-each-ref --format \"%(refname:short)\" refs/heads/ambiguous refs/tags/ambiguous >actual &&\n@@ -705,8 +706,8 @@ body contents\n $sig\"\n \n test_expect_success 'set up refs pointing to tree and blob' '\n-\tgit update-ref refs/mytrees/first refs/heads/master^{tree} &&\n-\tgit update-ref refs/myblobs/first refs/heads/master:one\n+\tgit update-ref refs/mytrees/first refs/heads/main^{tree} &&\n+\tgit update-ref refs/myblobs/first refs/heads/main:one\n '\n \n test_atom refs/mytrees/first subject \"\"\n@@ -778,7 +779,7 @@ test_expect_success 'equivalent sorts fall back on refname' '\n '\n \n test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '\n-\ttest_when_finished \"git checkout master\" &&\n+\ttest_when_finished \"git checkout main\" &&\n \tgit for-each-ref --format=\"%(HEAD) %(refname:short)\" refs/heads/ >actual &&\n \tsed -e \"s/^\\* /  /\" actual >expect &&\n \tgit checkout --orphan orphaned-branch &&\n@@ -815,9 +816,9 @@ test_expect_success '%(trailers:unfold) unfolds trailers' '\n \t\tunfold <trailers\n \t\techo\n \t} >expect &&\n-\tgit for-each-ref --format=\"%(trailers:unfold)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(trailers:unfold)\" refs/heads/main >actual &&\n \ttest_cmp expect actual &&\n-\tgit for-each-ref --format=\"%(contents:trailers:unfold)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(contents:trailers:unfold)\" refs/heads/main >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -826,9 +827,9 @@ test_expect_success '%(trailers:only) shows only \"key: value\" trailers' '\n \t\tgrep -v patch.description <trailers &&\n \t\techo\n \t} >expect &&\n-\tgit for-each-ref --format=\"%(trailers:only)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(trailers:only)\" refs/heads/main >actual &&\n \ttest_cmp expect actual &&\n-\tgit for-each-ref --format=\"%(contents:trailers:only)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(contents:trailers:only)\" refs/heads/main >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -837,13 +838,13 @@ test_expect_success '%(trailers:only) and %(trailers:unfold) work together' '\n \t\tgrep -v patch.description <trailers | unfold &&\n \t\techo\n \t} >expect &&\n-\tgit for-each-ref --format=\"%(trailers:only,unfold)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(trailers:only,unfold)\" refs/heads/main >actual &&\n \ttest_cmp expect actual &&\n-\tgit for-each-ref --format=\"%(trailers:unfold,only)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(trailers:unfold,only)\" refs/heads/main >actual &&\n \ttest_cmp actual actual &&\n-\tgit for-each-ref --format=\"%(contents:trailers:only,unfold)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(contents:trailers:only,unfold)\" refs/heads/main >actual &&\n \ttest_cmp expect actual &&\n-\tgit for-each-ref --format=\"%(contents:trailers:unfold,only)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(contents:trailers:unfold,only)\" refs/heads/main >actual &&\n \ttest_cmp actual actual\n '\n \n@@ -867,7 +868,7 @@ test_expect_success 'if arguments, %(contents:trailers) shows error if colon is\n '\n \n test_expect_success 'basic atom: head contents:trailers' '\n-\tgit for-each-ref --format=\"%(contents:trailers)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(contents:trailers)\" refs/heads/main >actual &&\n \tsanitize_pgp <actual >actual.clean &&\n \t# git for-each-ref ends with a blank line\n \tcat >expect <<-EOF &&\n@@ -896,16 +897,16 @@ test_expect_success 'trailer parsing not fooled by --- line' '\n \t\techo \"trailer: right\" &&\n \t\techo\n \t} >expect &&\n-\tgit for-each-ref --format=\"%(trailers)\" refs/heads/master >actual &&\n+\tgit for-each-ref --format=\"%(trailers)\" refs/heads/main >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'Add symbolic ref for the following tests' '\n-\tgit symbolic-ref refs/heads/sym refs/heads/master\n+\tgit symbolic-ref refs/heads/sym refs/heads/main\n '\n \n cat >expected <<EOF\n-refs/heads/master\n+refs/heads/main\n EOF\n \n test_expect_success 'Verify usage of %(symref) atom' '\n@@ -914,7 +915,7 @@ test_expect_success 'Verify usage of %(symref) atom' '\n '\n \n cat >expected <<EOF\n-heads/master\n+heads/main\n EOF\n \n test_expect_success 'Verify usage of %(symref:short) atom' '\n@@ -923,8 +924,8 @@ test_expect_success 'Verify usage of %(symref:short) atom' '\n '\n \n cat >expected <<EOF\n-master\n-heads/master\n+main\n+heads/main\n EOF\n \n test_expect_success 'Verify usage of %(symref:lstrip) atom' '\n@@ -953,22 +954,23 @@ test_expect_success ':remotename and :remoteref' '\n \t(\n \t\tcd remote-tests &&\n \t\ttest_commit initial &&\n+\t\tgit branch -M main &&\n \t\tgit remote add from fifth.coffee:blub &&\n-\t\tgit config branch.master.remote from &&\n-\t\tgit config branch.master.merge refs/heads/stable &&\n+\t\tgit config branch.main.remote from &&\n+\t\tgit config branch.main.merge refs/heads/stable &&\n \t\tgit remote add to southridge.audio:repo &&\n \t\tgit config remote.to.push \"refs/heads/*:refs/heads/pushed/*\" &&\n-\t\tgit config branch.master.pushRemote to &&\n+\t\tgit config branch.main.pushRemote to &&\n \t\tfor pair in \"%(upstream)=refs/remotes/from/stable\" \\\n \t\t\t\"%(upstream:remotename)=from\" \\\n \t\t\t\"%(upstream:remoteref)=refs/heads/stable\" \\\n-\t\t\t\"%(push)=refs/remotes/to/pushed/master\" \\\n+\t\t\t\"%(push)=refs/remotes/to/pushed/main\" \\\n \t\t\t\"%(push:remotename)=to\" \\\n-\t\t\t\"%(push:remoteref)=refs/heads/pushed/master\"\n+\t\t\t\"%(push:remoteref)=refs/heads/pushed/main\"\n \t\tdo\n \t\t\techo \"${pair#*=}\" >expect &&\n \t\t\tgit for-each-ref --format=\"${pair%=*}\" \\\n-\t\t\t\trefs/heads/master >actual &&\n+\t\t\t\trefs/heads/main >actual &&\n \t\t\ttest_cmp expect actual\n \t\tdone &&\n \t\tgit branch push-simple &&\n@@ -981,12 +983,12 @@ test_expect_success ':remotename and :remoteref' '\n '\n \n test_expect_success 'for-each-ref --ignore-case ignores case' '\n-\tgit for-each-ref --format=\"%(refname)\" refs/heads/MASTER >actual &&\n+\tgit for-each-ref --format=\"%(refname)\" refs/heads/MAIN >actual &&\n \ttest_must_be_empty actual &&\n \n-\techo refs/heads/master >expect &&\n+\techo refs/heads/main >expect &&\n \tgit for-each-ref --format=\"%(refname)\" --ignore-case \\\n-\t\trefs/heads/MASTER >actual &&\n+\t\trefs/heads/MAIN >actual &&\n \ttest_cmp expect actual\n '\n \n\nbase-commit: 3a0b884caba2752da0af626fb2de7d597c844e8b\n-- \ngitgitgadget\n"}]}