Re: [PATCH 4/8] push tests: assert re-pushing annotated tags
> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh > index c9a2011915..71fc902062 100755 > --- a/t/t5516-fetch-push.sh > +++ b/t/t5516-fetch-push.sh > @@ -965,35 +965,43 @@ test_expect_success 'push into aliased refs > (inconsistent)' ' > ) > ' > > -test_expect_success 'push requires --force to update lightweight tag' ' > - mk_test testrepo heads/master && > - mk_child testrepo child1 && > - mk_child testrepo child2 && > - ( > - cd child1 && > - git tag Tag && > - git push ../child2 Tag && > - >file1 && > - git add file1 && > - git commit -m "file1" && > - git tag -f Tag && > - test_must_fail git push ../child2 Tag && > - git push --force ../child2 Tag && > - git tag -f Tag HEAD~ && > - test_must_fail git push ../child2 Tag && > - git push --force ../child2 Tag && > - git tag -f Tag && > - test_must_fail git push ../child2 "refs/tags/*:refs/tags/*" && > - git push --force ../child2 "refs/tags/*:refs/tags/*" && > - git tag -f Tag HEAD~ && > - git push ../child2 "+refs/tags/*:refs/tags/*" && > - git tag -f Tag && > - git push --no-force ../child2 "+refs/tags/*:refs/tags/*" && > - git tag -f Tag HEAD~ && > - test_must_fail git push ../child2 tag Tag && > - git push --force ../child2 tag Tag > - ) > -' > +test_force_push_tag () { > + tag_type_description=$1 > + tag_args=$2 > + > + test_expect_success "push requires --force to update > $tag_type_description" " > + mk_test testrepo heads/master && > + mk_child testrepo child1 && > + mk_child testrepo child2 && > + ( > + cd child1 && > + git tag Tag && > + git push ../child2 Tag && > + >file1 && > + git add file1 && > + git commit -m 'file1' && > + git tag $tag_args Tag && > + test_must_fail git push ../child2 Tag && > + git push --force ../child2 Tag && > + git tag $tag_args Tag HEAD~ && > + test_must_fail git push ../child2 Tag && > + git push --force ../child2 Tag && > + git tag $tag_args Tag && > + test_must_fail git push ../child2 > 'refs/tags/*:refs/tags/*' && > + git push --force ../child2 'refs/tags/*:refs/tags/*' && > + git tag $tag_args Tag HEAD~ && > + git push ../child2 '+refs/tags/*:refs/tags/*' && > + git tag $tag_args Tag & There is that unwanted "function" at the end of the line. Interstingly, the test does pass when run with dash, but fails the chain-lint tests when run with Bash, even though it's in a subshell. > + git push --no-force ../child2 > '+refs/tags/*:refs/tags/*' && > + git tag $tag_args Tag HEAD~ && > + test_must_fail git push ../child2 tag Tag && > + git push --force ../child2 tag Tag > + ) > + " > +} > + > +test_force_push_tag "lightweight tag" "-f" > +test_force_push_tag "annotated tag" "-f -a -m'msg'" > > test_expect_success 'push --porcelain' ' > mk_empty testrepo &&
Re: [PATCH 4/8] push tests: assert re-pushing annotated tags
Ævar Arnfjörð Bjarmasonwrites: > Change the test that asserts that lightweight tags can only be > clobbered by a force-push to check do the same tests for annotated > tags. > > There used to be less exhaustive tests for this with the code added in > 40eff17999 ("push: require force for annotated tags", 2012-11-29), but > Junio removed them in 256b9d70a4 ("push: fix "refs/tags/ hierarchy > cannot be updated without --force"", 2013-01-16) while fixing some of > the behavior around tag pushing. > > That change left us without any coverage asserting that pushing and > clobbering annotated tags worked as intended. There was no reason to > suspect that the receive machinery wouldn't behave the same way with > annotated tags, but now we know for sure. Hmm, I am not sure if annotated tag T1 on commit C1 should be called to "fast-forward to annotated tag T2 on commit C2" when C2 is a descendant of C1. Tag is meant to be a non-moving anchor point, so it may make sense not to allow "fast-forwarding hence it is OK to replace" that is typical for branch heads, which are meant to move "forward". But let's move on and keep reading, at least temporarily assuming that "fast-forwarding" annotated tags makes sense. Under that assumption, this patch makes perfect sense to ensure lightweight and annotated tags behave the same. Thanks.
[PATCH 4/8] push tests: assert re-pushing annotated tags
Change the test that asserts that lightweight tags can only be clobbered by a force-push to check do the same tests for annotated tags. There used to be less exhaustive tests for this with the code added in 40eff17999 ("push: require force for annotated tags", 2012-11-29), but Junio removed them in 256b9d70a4 ("push: fix "refs/tags/ hierarchy cannot be updated without --force"", 2013-01-16) while fixing some of the behavior around tag pushing. That change left us without any coverage asserting that pushing and clobbering annotated tags worked as intended. There was no reason to suspect that the receive machinery wouldn't behave the same way with annotated tags, but now we know for sure. Signed-off-by: Ævar Arnfjörð Bjarmason--- t/t5516-fetch-push.sh | 66 --- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index c9a2011915..71fc902062 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -965,35 +965,43 @@ test_expect_success 'push into aliased refs (inconsistent)' ' ) ' -test_expect_success 'push requires --force to update lightweight tag' ' - mk_test testrepo heads/master && - mk_child testrepo child1 && - mk_child testrepo child2 && - ( - cd child1 && - git tag Tag && - git push ../child2 Tag && - >file1 && - git add file1 && - git commit -m "file1" && - git tag -f Tag && - test_must_fail git push ../child2 Tag && - git push --force ../child2 Tag && - git tag -f Tag HEAD~ && - test_must_fail git push ../child2 Tag && - git push --force ../child2 Tag && - git tag -f Tag && - test_must_fail git push ../child2 "refs/tags/*:refs/tags/*" && - git push --force ../child2 "refs/tags/*:refs/tags/*" && - git tag -f Tag HEAD~ && - git push ../child2 "+refs/tags/*:refs/tags/*" && - git tag -f Tag && - git push --no-force ../child2 "+refs/tags/*:refs/tags/*" && - git tag -f Tag HEAD~ && - test_must_fail git push ../child2 tag Tag && - git push --force ../child2 tag Tag - ) -' +test_force_push_tag () { + tag_type_description=$1 + tag_args=$2 + + test_expect_success "push requires --force to update $tag_type_description" " + mk_test testrepo heads/master && + mk_child testrepo child1 && + mk_child testrepo child2 && + ( + cd child1 && + git tag Tag && + git push ../child2 Tag && + >file1 && + git add file1 && + git commit -m 'file1' && + git tag $tag_args Tag && + test_must_fail git push ../child2 Tag && + git push --force ../child2 Tag && + git tag $tag_args Tag HEAD~ && + test_must_fail git push ../child2 Tag && + git push --force ../child2 Tag && + git tag $tag_args Tag && + test_must_fail git push ../child2 'refs/tags/*:refs/tags/*' && + git push --force ../child2 'refs/tags/*:refs/tags/*' && + git tag $tag_args Tag HEAD~ && + git push ../child2 '+refs/tags/*:refs/tags/*' && + git tag $tag_args Tag & + git push --no-force ../child2 '+refs/tags/*:refs/tags/*' && + git tag $tag_args Tag HEAD~ && + test_must_fail git push ../child2 tag Tag && + git push --force ../child2 tag Tag + ) + " +} + +test_force_push_tag "lightweight tag" "-f" +test_force_push_tag "annotated tag" "-f -a -m'msg'" test_expect_success 'push --porcelain' ' mk_empty testrepo && -- 2.17.0.290.gded63e768a