Re: [PATCH v3] receive-pack: Create a HEAD ref for ref namespace
On 05/06, Junio C Hamano wrote: Johannes Löthberg writes: + + echo "ref: refs/namespaces/new_namespace/refs/heads/master" >expect && + test_cmp expect ../bare/refs/namespaces/new_namespace/HEAD && Use "symbolic-ref refs/namespaces/new_namespace/HEAD"; HEAD is not required to be expressed as a textual symref. Gotcha. + + ( + printf "%s commit\t%s\n" $(git rev-parse master^) \ +refs/heads/master && + printf "%s commit\t%s\n" $(git rev-parse master) \ +refs/namespaces/new_namespace/HEAD && + printf "%s commit\t%s\n" $(git rev-parse master) \ + refs/namespaces/new_namespace/refs/heads/master + ) >expect && Use of 'printf' is clever and I like it. Have you considered letting it do the iteration as well? I.e. printf "%s commit\t%s\n" \ one two \ three four \ five six \ >expect && might be easier to read. Didn't think about that actually. Will do. + git -C ../bare for-each-ref refs/ >actual && + test_cmp expect actual + ) && + GIT_NAMESPACE=new_namespace git clone bare clone && + ( + cd clone && + git show We can accept any random commit at HEAD as long as it exists at this point? Don't we need to make sure that a ref whose tip is still "one" is not propagated to this new clone? Oh crap, I just remembered that I forgot to address that part, sorry. + ) +' + + test_done -- Sincerely, Johannes Löthberg PGP Key ID: 0x50FB9B273A9D0BB5 https://theos.kyriasis.com/~kyrias/ signature.asc Description: PGP signature
Re: [PATCH v3] receive-pack: Create a HEAD ref for ref namespace
Johannes Löthberg writes: > diff --git a/t/t5509-fetch-push-namespaces.sh > b/t/t5509-fetch-push-namespaces.sh > index cc0b31f..7bc3a1f 100755 > --- a/t/t5509-fetch-push-namespaces.sh > +++ b/t/t5509-fetch-push-namespaces.sh > @@ -1,6 +1,7 @@ > #!/bin/sh > > -test_description='fetch/push involving ref namespaces' > +test_description='fetch/push/clone involving ref namespaces' > + OK ;-) > . ./test-lib.sh > > test_expect_success setup ' > @@ -82,4 +83,50 @@ test_expect_success 'mirroring a repository using a ref > namespace' ' > ) > ' > > +test_expect_success 'cloning from ref namespace' ' > + rm -rf initial bare clone && > + git init initial && > + git init --bare bare && > + ( > + cd initial && > + echo "commit one" >file && > + git add file && > + git commit -m "commit one" && > + git push ../bare master && > + > + echo refs/heads/master >expect && > + git -C ../bare symbolic-ref HEAD >actual && > + test_cmp expect actual && > + > + git rev-parse HEAD >expect && > + git -C ../bare rev-parse HEAD >actual && > + test_cmp expect actual && > + > + echo "commit two" >>file && > + git add file && > + git commit -m "commit two" && > + GIT_NAMESPACE=new_namespace git push ../bare master && > + > + echo "ref: refs/namespaces/new_namespace/refs/heads/master" > >expect && > + test_cmp expect ../bare/refs/namespaces/new_namespace/HEAD && Use "symbolic-ref refs/namespaces/new_namespace/HEAD"; HEAD is not required to be expressed as a textual symref. > + > + ( > + printf "%s commit\t%s\n" $(git rev-parse master^) \ > + refs/heads/master && > + printf "%s commit\t%s\n" $(git rev-parse master) \ > + > refs/namespaces/new_namespace/HEAD && > + printf "%s commit\t%s\n" $(git rev-parse master) \ > + > refs/namespaces/new_namespace/refs/heads/master > + ) >expect && Use of 'printf' is clever and I like it. Have you considered letting it do the iteration as well? I.e. printf "%s commit\t%s\n" \ one two \ three four \ five six \ >expect && might be easier to read. > + git -C ../bare for-each-ref refs/ >actual && > + test_cmp expect actual > + ) && > + GIT_NAMESPACE=new_namespace git clone bare clone && > + ( > + cd clone && > + git show We can accept any random commit at HEAD as long as it exists at this point? Don't we need to make sure that a ref whose tip is still "one" is not propagated to this new clone? > + ) > +' > + > + > test_done -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] receive-pack: Create a HEAD ref for ref namespace
I should also look into why the other tests in t5509 fail later. -- Sincerely, Johannes Löthberg PGP Key ID: 0x50FB9B273A9D0BB5 https://theos.kyriasis.com/~kyrias/ signature.asc Description: PGP signature