diff mbox series

[2/2] tests: avoid using the branch name `main`

Message ID 6045ceb938836355b7d43bc2088ca2504b05dde4.1601888196.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Avoid main as branch name in the test suite | expand

Commit Message

Philippe Blain via GitGitGadget Oct. 5, 2020, 8:56 a.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In the near future, we want to change Git's default branch name to
`main`. In preparation for that, stop using it as a branch name in the
test suite. Replace that branch name by `primary`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t6012-rev-list-simplify.sh |  8 ++++----
 t/t6400-merge-df.sh          |  8 ++++----
 t/t6409-merge-subtree.sh     | 12 ++++++------
 t/t6430-merge-recursive.sh   |  4 ++--
 4 files changed, 16 insertions(+), 16 deletions(-)

Comments

Jonathan Nieder Oct. 5, 2020, 9:59 a.m. UTC | #1
Johannes Schindelin wrote:

> In the near future, we want to change Git's default branch name to
> `main`. In preparation for that, stop using it as a branch name in the
> test suite. Replace that branch name by `primary`.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  t/t6012-rev-list-simplify.sh |  8 ++++----
>  t/t6400-merge-df.sh          |  8 ++++----
>  t/t6409-merge-subtree.sh     | 12 ++++++------
>  t/t6430-merge-recursive.sh   |  4 ++--
>  4 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
> index b6fa43ace0..f1296c29e6 100755
> --- a/t/t6012-rev-list-simplify.sh
> +++ b/t/t6012-rev-list-simplify.sh
> @@ -171,7 +171,7 @@ test_expect_success '--full-diff is not affected by --parents' '
>  test_expect_success 'rebuild repo' '
>  	rm -rf .git * &&
>  	git init &&
> -	git switch -c main &&
> +	git switch -c primary &&

Is there a secondary corresponding to this primary?

I guess the idea is that this is the trunk that other branches branch
from?  Looking at the history, it seems that this test was added
relatively recently and it may have had the upcoming branch name change
in mind (or in other words if it were an older test it might be expected
to use "master").

That suggests an alternative that is agnostic to init.defaultBranch:
what if this uses "git switch -C main"?

Thanks,
Jonathan
Johannes Schindelin Oct. 8, 2020, 8:05 a.m. UTC | #2
Hi Jonathan,

On Mon, 5 Oct 2020, Jonathan Nieder wrote:

> Johannes Schindelin wrote:
>
> > In the near future, we want to change Git's default branch name to
> > `main`. In preparation for that, stop using it as a branch name in the
> > test suite. Replace that branch name by `primary`.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  t/t6012-rev-list-simplify.sh |  8 ++++----
> >  t/t6400-merge-df.sh          |  8 ++++----
> >  t/t6409-merge-subtree.sh     | 12 ++++++------
> >  t/t6430-merge-recursive.sh   |  4 ++--
> >  4 files changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
> > index b6fa43ace0..f1296c29e6 100755
> > --- a/t/t6012-rev-list-simplify.sh
> > +++ b/t/t6012-rev-list-simplify.sh
> > @@ -171,7 +171,7 @@ test_expect_success '--full-diff is not affected by --parents' '
> >  test_expect_success 'rebuild repo' '
> >  	rm -rf .git * &&
> >  	git init &&
> > -	git switch -c main &&
> > +	git switch -c primary &&
>
> Is there a secondary corresponding to this primary?

Nope, of course not ;-)

> I guess the idea is that this is the trunk that other branches branch
> from?  Looking at the history, it seems that this test was added
> relatively recently and it may have had the upcoming branch name change
> in mind (or in other words if it were an older test it might be expected
> to use "master").

I guess that Stolee (Cc:ed) had something like that in mind.

When I look at 8d049e182e2 (revision: --show-pulls adds helpful
merges, 2020-04-10), I get the impression that does not _really_ care
about the name of the main branch, it just wants to know the name so it
can switch back and forth.

If I had had the presence of mind when reviewing that patch back in April,
I would probably have advocated for the use of `git switch -`...

In any case, I would like to keep this consistent with the remainder of
the test scripts modified by this patch, and use the relatively neutral
`topic` here.

Ciao,
Dscho

> That suggests an alternative that is agnostic to init.defaultBranch:
> what if this uses "git switch -C main"?
>
> Thanks,
> Jonathan
>
diff mbox series

Patch

diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
index b6fa43ace0..f1296c29e6 100755
--- a/t/t6012-rev-list-simplify.sh
+++ b/t/t6012-rev-list-simplify.sh
@@ -171,7 +171,7 @@  test_expect_success '--full-diff is not affected by --parents' '
 test_expect_success 'rebuild repo' '
 	rm -rf .git * &&
 	git init &&
-	git switch -c main &&
+	git switch -c primary &&
 
 	echo base >file &&
 	git add file &&
@@ -186,7 +186,7 @@  test_expect_success 'rebuild repo' '
 	git add file &&
 	test_commit B &&
 
-	git switch main &&
+	git switch primary &&
 	test_must_fail git merge -m "M" B &&
 	echo A >file &&
 	echo B >>file &&
@@ -207,7 +207,7 @@  test_expect_success 'rebuild repo' '
 	git merge -m R -Xtheirs X &&
 	note R &&
 
-	git switch main &&
+	git switch primary &&
 	git merge -m N R &&
 	note N &&
 
@@ -221,7 +221,7 @@  test_expect_success 'rebuild repo' '
 	git add z &&
 	test_commit Z &&
 
-	git switch main &&
+	git switch primary &&
 	git merge -m O Z &&
 	note O &&
 
diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh
index 400a4cd139..15f540aae3 100755
--- a/t/t6400-merge-df.sh
+++ b/t/t6400-merge-df.sh
@@ -124,7 +124,7 @@  test_expect_success 'Simple merge in repo with interesting pathnames' '
 		git add . &&
 		git commit -m initial &&
 
-		git branch main &&
+		git branch primary &&
 		git branch other &&
 
 		git checkout other &&
@@ -132,10 +132,10 @@  test_expect_success 'Simple merge in repo with interesting pathnames' '
 		git add -u &&
 		git commit -m other &&
 
-		git checkout main &&
-		echo main >foo/bar/baz &&
+		git checkout primary &&
+		echo primary >foo/bar/baz &&
 		git add -u &&
-		git commit -m main &&
+		git commit -m primary &&
 
 		git merge other &&
 		git ls-files -s >out &&
diff --git a/t/t6409-merge-subtree.sh b/t/t6409-merge-subtree.sh
index 793f0c8bf3..c236180238 100755
--- a/t/t6409-merge-subtree.sh
+++ b/t/t6409-merge-subtree.sh
@@ -35,11 +35,11 @@  test_expect_success 'setup branch sub' '
 	test_commit foo
 '
 
-test_expect_success 'setup branch main' '
-	git checkout -b main master &&
+test_expect_success 'setup branch primary' '
+	git checkout -b primary master &&
 	git merge -s ours --no-commit --allow-unrelated-histories sub &&
 	git read-tree --prefix=dir/ -u sub &&
-	git commit -m "initial merge of sub into main" &&
+	git commit -m "initial merge of sub into primary" &&
 	test_path_is_file dir/foo.t &&
 	test_path_is_file hello
 '
@@ -49,9 +49,9 @@  test_expect_success 'update branch sub' '
 	test_commit bar
 '
 
-test_expect_success 'update branch main' '
-	git checkout main &&
-	git merge -s subtree sub -m "second merge of sub into main" &&
+test_expect_success 'update branch primary' '
+	git checkout primary &&
+	git merge -s subtree sub -m "second merge of sub into primary" &&
 	test_path_is_file dir/bar.t &&
 	test_path_is_file dir/foo.t &&
 	test_path_is_file hello
diff --git a/t/t6430-merge-recursive.sh b/t/t6430-merge-recursive.sh
index d48d211a95..900e5c63a7 100755
--- a/t/t6430-merge-recursive.sh
+++ b/t/t6430-merge-recursive.sh
@@ -663,7 +663,7 @@  test_expect_failure 'merge-recursive rename vs. rename/symlink' '
 
 test_expect_success 'merging with triple rename across D/F conflict' '
 	git reset --hard HEAD &&
-	git checkout -b main &&
+	git checkout -b primary &&
 	git rm -rf . &&
 
 	echo "just a file" >sub1 &&
@@ -682,7 +682,7 @@  test_expect_success 'merging with triple rename across D/F conflict' '
 	test_tick &&
 	git commit -a -m changesimplefile &&
 
-	git checkout main &&
+	git checkout primary &&
 	git rm sub1 &&
 	git mv sub2 sub1 &&
 	test_tick &&