git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SQUASH??? allow t0031 to run with any default branch name
@ 2021-03-11 18:01 Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2021-03-11 18:01 UTC (permalink / raw)
  To: Han-Wen Nienhuys; +Cc: git

I no longer remember which step in your multi-patch series
introduces this script or these are built-up incrementally, but I've
been carrying this patch at the tip of the series so that merging it
to 'seen' (or any other interation branch) would not make the result
fail depending on the hardcoded default fallback name for the first
branch.  Can you update your series so that I do not have to [*]?

Thanks.

[footnote]

* meaning, either squash into the commit that adds the t0031 test
  script, if the entire test is created in a single commit, or pick
  the parts of this patch apart and sprinkle the fixes to the commit
  that introduces t0031 and subsequent commits that updates it.

 t/t0031-reftable.sh | 54 ++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/t/t0031-reftable.sh b/t/t0031-reftable.sh
index 58c7d5d4bc..ba0738e515 100755
--- a/t/t0031-reftable.sh
+++ b/t/t0031-reftable.sh
@@ -9,23 +9,27 @@ test_description='reftable basics'
 
 INVALID_SHA1=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
+git_init () {
+	git init -b primary "$@"
+}
+
 initialize ()  {
 	rm -rf .git &&
-	git init --ref-storage=reftable &&
+	git_init --ref-storage=reftable &&
 	mv .git/hooks .git/hooks-disabled
 }
 
 test_expect_success 'SHA256 support, env' '
 	rm -rf .git &&
 	GIT_DEFAULT_HASH=sha256 && export GIT_DEFAULT_HASH &&
-	git init --ref-storage=reftable &&
+	git_init --ref-storage=reftable &&
 	mv .git/hooks .git/hooks-disabled &&
 	test_commit file
 '
 
 test_expect_success 'SHA256 support, option' '
 	rm -rf .git &&
-	git init --ref-storage=reftable --object-format=sha256 &&
+	git_init --ref-storage=reftable --object-format=sha256 &&
 	mv .git/hooks .git/hooks-disabled &&
 	test_commit file
 '
@@ -34,13 +38,13 @@ test_expect_success 'delete ref' '
 	initialize &&
 	test_commit file &&
 	SHA=$(git show-ref -s --verify HEAD) &&
-	test_write_lines "$SHA refs/heads/master" "$SHA refs/tags/file" >expect &&
-	git show-ref > actual &&
+	test_write_lines "$SHA refs/heads/primary" "$SHA refs/tags/file" >expect &&
+	git show-ref >actual &&
 	! git update-ref -d refs/tags/file $INVALID_SHA1 &&
 	test_cmp expect actual &&
 	git update-ref -d refs/tags/file $SHA  &&
-	test_write_lines "$SHA refs/heads/master" >expect &&
-	git show-ref > actual &&
+	test_write_lines "$SHA refs/heads/primary" >expect &&
+	git show-ref >actual &&
 	test_cmp expect actual
 '
 
@@ -54,9 +58,9 @@ test_expect_success 'clone calls transaction_initial_commit' '
 test_expect_success 'basic operation of reftable storage: commit, show-ref' '
 	initialize &&
 	test_commit file &&
-	test_write_lines refs/heads/master refs/tags/file >expect &&
+	test_write_lines refs/heads/primary refs/tags/file >expect &&
 	git show-ref &&
-	git show-ref | cut -f2 -d" " > actual &&
+	git show-ref | cut -f2 -d" " >actual &&
 	test_cmp actual expect
 '
 
@@ -70,12 +74,12 @@ test_expect_success 'reflog, repack' '
 	git pack-refs &&
 	ls -1 .git/reftable >table-files &&
 	test_line_count = 2 table-files &&
-	git reflog refs/heads/master >output &&
+	git reflog refs/heads/primary >output &&
 	test_line_count = 10 output &&
 	grep "commit (initial): number 1" output &&
 	grep "commit: number 10" output &&
 	git gc &&
-	git reflog refs/heads/master >output &&
+	git reflog refs/heads/primary >output &&
 	test_line_count = 0 output
 '
 
@@ -86,8 +90,8 @@ test_expect_success 'branch switch in reflog output' '
 	test_commit file2 &&
 	git checkout -b branch2 &&
 	git switch - &&
-	git rev-parse --symbolic-full-name HEAD > actual &&
-	echo refs/heads/branch1 > expect &&
+	git rev-parse --symbolic-full-name HEAD >actual &&
+	echo refs/heads/branch1 >expect &&
 	test_cmp actual expect
 '
 
@@ -102,7 +106,7 @@ test_expect_success 'peeled tags are stored' '
 	test_commit file &&
 	git tag -m "annotated tag" test_tag HEAD &&
 	{
-		print_ref "refs/heads/master" &&
+		print_ref "refs/heads/primary" &&
 		print_ref "refs/tags/file" &&
 		print_ref "refs/tags/test_tag" &&
 		print_ref "refs/tags/test_tag^{}"
@@ -114,32 +118,32 @@ test_expect_success 'peeled tags are stored' '
 test_expect_success 'show-ref works on fresh repo' '
 	initialize &&
 	rm -rf .git &&
-	git init --ref-storage=reftable &&
+	git_init --ref-storage=reftable &&
 	>expect &&
-	! git show-ref > actual &&
+	! git show-ref >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'checkout unborn branch' '
 	initialize &&
-	git checkout -b master
+	git checkout -b primary
 '
 
 
 test_expect_success 'dir/file conflict' '
 	initialize &&
 	test_commit file &&
-	! git branch master/forbidden
+	! git branch primary/forbidden
 '
 
 
 test_expect_success 'do not clobber existing repo' '
 	rm -rf .git &&
-	git init --ref-storage=files &&
-	cat .git/HEAD > expect &&
+	git_init --ref-storage=files &&
+	cat .git/HEAD >expect &&
 	test_commit file &&
-	(git init --ref-storage=reftable || true) &&
-	cat .git/HEAD > actual &&
+	(git_init --ref-storage=reftable || true) &&
+	cat .git/HEAD >actual &&
 	test_cmp expect actual
 '
 
@@ -168,7 +172,7 @@ test_expect_success 'rebase' '
 '
 
 test_expect_success 'worktrees' '
-	git init --ref-storage=reftable start &&
+	git_init --ref-storage=reftable start &&
 	(cd start && test_commit file1 && git checkout -b branch1 &&
 	git checkout -b branch2 &&
 	git worktree add  ../wt
@@ -182,13 +186,13 @@ test_expect_success 'worktrees 2' '
 	initialize &&
 	test_commit file1 &&
 	mkdir existing_empty &&
-	git worktree add --detach existing_empty master
+	git worktree add --detach existing_empty primary
 '
 
 test_expect_success 'FETCH_HEAD' '
 	initialize &&
 	test_commit one &&
-	(git init sub && cd sub && test_commit two) &&
+	(git_init sub && cd sub && test_commit two) &&
 	git --git-dir sub/.git rev-parse HEAD >expect &&
 	git fetch sub &&
 	git checkout FETCH_HEAD &&
-- 
2.31.0-rc2-173-g36b77366ca


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] SQUASH??? allow t0031 to run with any default branch name
  2020-12-21 19:55     ` [PATCH] SQUASH??? allow t0031 to run with any default branch name Junio C Hamano
  2020-12-21 20:19       ` Felipe Contreras
@ 2020-12-22 10:22       ` Han-Wen Nienhuys
  1 sibling, 0 replies; 4+ messages in thread
From: Han-Wen Nienhuys @ 2020-12-22 10:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Dec 21, 2020 at 8:55 PM Junio C Hamano <gitster@pobox.com> wrote:
> I'll queue the following on tip to force the test pass, but please
> squash it into an appropriate step in the patch series; fixing it in
> a different way may also be acceptable and welcome, if you or others
> can come up with a cleaner way to do so.

thanks, I've folded this patch in.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] SQUASH??? allow t0031 to run with any default branch name
  2020-12-21 19:55     ` [PATCH] SQUASH??? allow t0031 to run with any default branch name Junio C Hamano
@ 2020-12-21 20:19       ` Felipe Contreras
  2020-12-22 10:22       ` Han-Wen Nienhuys
  1 sibling, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2020-12-21 20:19 UTC (permalink / raw)
  To: Junio C Hamano, Han-Wen Nienhuys; +Cc: git

Junio C Hamano wrote:
> It seems that we should stop assuming what the name of the default
> branch is in a new repository.  One good way to do so would be to
> change "git init" to "git init -b primary" so that the tests won't
> get affected whether the default name is master or main or any other
> value, and then use 'primary' throughout the name, instead of
> assuming 'master' will stay to be the name used when unspecified
> forever.

A better name would be "initial".

Even in tests branch names should mean something, and in the context of
git, the master branch means the original branch from which all the
other branches were copied from (usually). In tests the primary branch
is not necessarily the master branch, so "primary" doesn't cut it.

Another option is "original".

If the meaning of the word is not defined yet, a placeholder can be "nonce".

Or if we don't want to assign any meaning at all, just "blank", "nil",
and of course "foobar".

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] SQUASH??? allow t0031 to run with any default branch name
  2020-12-21 18:01   ` Junio C Hamano
@ 2020-12-21 19:55     ` Junio C Hamano
  2020-12-21 20:19       ` Felipe Contreras
  2020-12-22 10:22       ` Han-Wen Nienhuys
  0 siblings, 2 replies; 4+ messages in thread
From: Junio C Hamano @ 2020-12-21 19:55 UTC (permalink / raw)
  To: Han-Wen Nienhuys; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

>>>  The "reftable" backend for the refs API.
>>>
>>>  Ejected for now, as it has been breaking the tip of 'seen' for too
>>>  long.
>>
>>
>> Can you provide more information here? The PR at
>> https://github.com/git/git/pull/847 passes all tests (except for the
>> VSBuild, with errors that seem unrelated.)
>
> Sorry, but it has been a long time that I have no more detail than
> the above handy.  Older CI history might know more, but I have no
> time to dig that right now (and I'd be just as efficient as you
> would for doing such things).
>
> I can try including it in one of the today's pushout of 'seen' and
> see what breaks, which would be the easiest ;-)
>
> Thanks for pinging.

I just pushed one this morning, the only change from yesterday's
'seen' is that it has hn/reftable at the tip.

  https://travis-ci.org/github/git/git/jobs/750888904

It seems that we should stop assuming what the name of the default
branch is in a new repository.  One good way to do so would be to
change "git init" to "git init -b primary" so that the tests won't
get affected whether the default name is master or main or any other
value, and then use 'primary' throughout the name, instead of
assuming 'master' will stay to be the name used when unspecified
forever.

I'll queue the following on tip to force the test pass, but please
squash it into an appropriate step in the patch series; fixing it in
a different way may also be acceptable and welcome, if you or others
can come up with a cleaner way to do so.

Thanks.

--- >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ------ >8 ---
Subject: [PATCH] SQUASH??? allow t0031 to run with any default branch name

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t0031-reftable.sh | 54 ++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/t/t0031-reftable.sh b/t/t0031-reftable.sh
index 58c7d5d4bc..ba0738e515 100755
--- a/t/t0031-reftable.sh
+++ b/t/t0031-reftable.sh
@@ -9,23 +9,27 @@ test_description='reftable basics'
 
 INVALID_SHA1=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
+git_init () {
+	git init -b primary "$@"
+}
+
 initialize ()  {
 	rm -rf .git &&
-	git init --ref-storage=reftable &&
+	git_init --ref-storage=reftable &&
 	mv .git/hooks .git/hooks-disabled
 }
 
 test_expect_success 'SHA256 support, env' '
 	rm -rf .git &&
 	GIT_DEFAULT_HASH=sha256 && export GIT_DEFAULT_HASH &&
-	git init --ref-storage=reftable &&
+	git_init --ref-storage=reftable &&
 	mv .git/hooks .git/hooks-disabled &&
 	test_commit file
 '
 
 test_expect_success 'SHA256 support, option' '
 	rm -rf .git &&
-	git init --ref-storage=reftable --object-format=sha256 &&
+	git_init --ref-storage=reftable --object-format=sha256 &&
 	mv .git/hooks .git/hooks-disabled &&
 	test_commit file
 '
@@ -34,13 +38,13 @@ test_expect_success 'delete ref' '
 	initialize &&
 	test_commit file &&
 	SHA=$(git show-ref -s --verify HEAD) &&
-	test_write_lines "$SHA refs/heads/master" "$SHA refs/tags/file" >expect &&
-	git show-ref > actual &&
+	test_write_lines "$SHA refs/heads/primary" "$SHA refs/tags/file" >expect &&
+	git show-ref >actual &&
 	! git update-ref -d refs/tags/file $INVALID_SHA1 &&
 	test_cmp expect actual &&
 	git update-ref -d refs/tags/file $SHA  &&
-	test_write_lines "$SHA refs/heads/master" >expect &&
-	git show-ref > actual &&
+	test_write_lines "$SHA refs/heads/primary" >expect &&
+	git show-ref >actual &&
 	test_cmp expect actual
 '
 
@@ -54,9 +58,9 @@ test_expect_success 'clone calls transaction_initial_commit' '
 test_expect_success 'basic operation of reftable storage: commit, show-ref' '
 	initialize &&
 	test_commit file &&
-	test_write_lines refs/heads/master refs/tags/file >expect &&
+	test_write_lines refs/heads/primary refs/tags/file >expect &&
 	git show-ref &&
-	git show-ref | cut -f2 -d" " > actual &&
+	git show-ref | cut -f2 -d" " >actual &&
 	test_cmp actual expect
 '
 
@@ -70,12 +74,12 @@ test_expect_success 'reflog, repack' '
 	git pack-refs &&
 	ls -1 .git/reftable >table-files &&
 	test_line_count = 2 table-files &&
-	git reflog refs/heads/master >output &&
+	git reflog refs/heads/primary >output &&
 	test_line_count = 10 output &&
 	grep "commit (initial): number 1" output &&
 	grep "commit: number 10" output &&
 	git gc &&
-	git reflog refs/heads/master >output &&
+	git reflog refs/heads/primary >output &&
 	test_line_count = 0 output
 '
 
@@ -86,8 +90,8 @@ test_expect_success 'branch switch in reflog output' '
 	test_commit file2 &&
 	git checkout -b branch2 &&
 	git switch - &&
-	git rev-parse --symbolic-full-name HEAD > actual &&
-	echo refs/heads/branch1 > expect &&
+	git rev-parse --symbolic-full-name HEAD >actual &&
+	echo refs/heads/branch1 >expect &&
 	test_cmp actual expect
 '
 
@@ -102,7 +106,7 @@ test_expect_success 'peeled tags are stored' '
 	test_commit file &&
 	git tag -m "annotated tag" test_tag HEAD &&
 	{
-		print_ref "refs/heads/master" &&
+		print_ref "refs/heads/primary" &&
 		print_ref "refs/tags/file" &&
 		print_ref "refs/tags/test_tag" &&
 		print_ref "refs/tags/test_tag^{}"
@@ -114,32 +118,32 @@ test_expect_success 'peeled tags are stored' '
 test_expect_success 'show-ref works on fresh repo' '
 	initialize &&
 	rm -rf .git &&
-	git init --ref-storage=reftable &&
+	git_init --ref-storage=reftable &&
 	>expect &&
-	! git show-ref > actual &&
+	! git show-ref >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'checkout unborn branch' '
 	initialize &&
-	git checkout -b master
+	git checkout -b primary
 '
 
 
 test_expect_success 'dir/file conflict' '
 	initialize &&
 	test_commit file &&
-	! git branch master/forbidden
+	! git branch primary/forbidden
 '
 
 
 test_expect_success 'do not clobber existing repo' '
 	rm -rf .git &&
-	git init --ref-storage=files &&
-	cat .git/HEAD > expect &&
+	git_init --ref-storage=files &&
+	cat .git/HEAD >expect &&
 	test_commit file &&
-	(git init --ref-storage=reftable || true) &&
-	cat .git/HEAD > actual &&
+	(git_init --ref-storage=reftable || true) &&
+	cat .git/HEAD >actual &&
 	test_cmp expect actual
 '
 
@@ -168,7 +172,7 @@ test_expect_success 'rebase' '
 '
 
 test_expect_success 'worktrees' '
-	git init --ref-storage=reftable start &&
+	git_init --ref-storage=reftable start &&
 	(cd start && test_commit file1 && git checkout -b branch1 &&
 	git checkout -b branch2 &&
 	git worktree add  ../wt
@@ -182,13 +186,13 @@ test_expect_success 'worktrees 2' '
 	initialize &&
 	test_commit file1 &&
 	mkdir existing_empty &&
-	git worktree add --detach existing_empty master
+	git worktree add --detach existing_empty primary
 '
 
 test_expect_success 'FETCH_HEAD' '
 	initialize &&
 	test_commit one &&
-	(git init sub && cd sub && test_commit two) &&
+	(git_init sub && cd sub && test_commit two) &&
 	git --git-dir sub/.git rev-parse HEAD >expect &&
 	git fetch sub &&
 	git checkout FETCH_HEAD &&
-- 
2.30.0-rc1-180-g539a9eda38


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-11 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 18:01 [PATCH] SQUASH??? allow t0031 to run with any default branch name Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2020-12-19  5:34 What's cooking in git.git (Dec 2020, #03; Fri, 18) Junio C Hamano
2020-12-21 12:40 ` Han-Wen Nienhuys
2020-12-21 18:01   ` Junio C Hamano
2020-12-21 19:55     ` [PATCH] SQUASH??? allow t0031 to run with any default branch name Junio C Hamano
2020-12-21 20:19       ` Felipe Contreras
2020-12-22 10:22       ` Han-Wen Nienhuys

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).