Skip to content

Commit 5f9cefa

Browse files
avargitster
authored andcommitted
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 40eff17 ("push: require force for annotated tags", 2012-11-29), but Junio removed them in 256b9d7 ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6c36880 commit 5f9cefa

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

t/t5516-fetch-push.sh

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -965,35 +965,43 @@ test_expect_success 'push into aliased refs (inconsistent)' '
965965
)
966966
'
967967

968-
test_expect_success 'push requires --force to update lightweight tag' '
969-
mk_test testrepo heads/master &&
970-
mk_child testrepo child1 &&
971-
mk_child testrepo child2 &&
972-
(
973-
cd child1 &&
974-
git tag Tag &&
975-
git push ../child2 Tag &&
976-
>file1 &&
977-
git add file1 &&
978-
git commit -m "file1" &&
979-
git tag -f Tag &&
980-
test_must_fail git push ../child2 Tag &&
981-
git push --force ../child2 Tag &&
982-
git tag -f Tag HEAD~ &&
983-
test_must_fail git push ../child2 Tag &&
984-
git push --force ../child2 Tag &&
985-
git tag -f Tag &&
986-
test_must_fail git push ../child2 "refs/tags/*:refs/tags/*" &&
987-
git push --force ../child2 "refs/tags/*:refs/tags/*" &&
988-
git tag -f Tag HEAD~ &&
989-
git push ../child2 "+refs/tags/*:refs/tags/*" &&
990-
git tag -f Tag &&
991-
git push --no-force ../child2 "+refs/tags/*:refs/tags/*" &&
992-
git tag -f Tag HEAD~ &&
993-
test_must_fail git push ../child2 tag Tag &&
994-
git push --force ../child2 tag Tag
995-
)
996-
'
968+
test_force_push_tag () {
969+
tag_type_description=$1
970+
tag_args=$2
971+
972+
test_expect_success "push requires --force to update $tag_type_description" "
973+
mk_test testrepo heads/master &&
974+
mk_child testrepo child1 &&
975+
mk_child testrepo child2 &&
976+
(
977+
cd child1 &&
978+
git tag Tag &&
979+
git push ../child2 Tag &&
980+
>file1 &&
981+
git add file1 &&
982+
git commit -m 'file1' &&
983+
git tag $tag_args Tag &&
984+
test_must_fail git push ../child2 Tag &&
985+
git push --force ../child2 Tag &&
986+
git tag $tag_args Tag HEAD~ &&
987+
test_must_fail git push ../child2 Tag &&
988+
git push --force ../child2 Tag &&
989+
git tag $tag_args Tag &&
990+
test_must_fail git push ../child2 'refs/tags/*:refs/tags/*' &&
991+
git push --force ../child2 'refs/tags/*:refs/tags/*' &&
992+
git tag $tag_args Tag HEAD~ &&
993+
git push ../child2 '+refs/tags/*:refs/tags/*' &&
994+
git tag $tag_args Tag &&function
995+
git push --no-force ../child2 '+refs/tags/*:refs/tags/*' &&
996+
git tag $tag_args Tag HEAD~ &&
997+
test_must_fail git push ../child2 tag Tag &&
998+
git push --force ../child2 tag Tag
999+
)
1000+
"
1001+
}
1002+
1003+
test_force_push_tag "lightweight tag" "-f"
1004+
test_force_push_tag "annotated tag" "-f -a -m'msg'"
9971005

9981006
test_expect_success 'push --porcelain' '
9991007
mk_empty testrepo &&

0 commit comments

Comments
 (0)