Skip to content

Commit 380efb6

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 941a7ba commit 380efb6

File tree

1 file changed

+45
-37
lines changed

1 file changed

+45
-37
lines changed

t/t5516-fetch-push.sh

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

968-
test_expect_success 'force pushing required 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 testTag &&
975-
git push ../child2 testTag &&
976-
>file1 &&
977-
git add file1 &&
978-
git commit -m "file1" &&
979-
git tag -f testTag &&
980-
test_must_fail git push ../child2 testTag &&
981-
git push --force ../child2 testTag &&
982-
git tag -f testTag HEAD~ &&
983-
test_must_fail git push ../child2 testTag &&
984-
git push --force ../child2 testTag &&
985-
986-
# Clobbering without + in refspec needs --force
987-
git tag -f testTag &&
988-
test_must_fail git push ../child2 "refs/tags/*:refs/tags/*" &&
989-
git push --force ../child2 "refs/tags/*:refs/tags/*" &&
990-
991-
# Clobbering with + in refspec does not need --force
992-
git tag -f testTag HEAD~ &&
993-
git push ../child2 "+refs/tags/*:refs/tags/*" &&
994-
995-
# Clobbering with --no-force still obeys + in refspec
996-
git tag -f testTag &&
997-
git push --no-force ../child2 "+refs/tags/*:refs/tags/*" &&
998-
999-
# Clobbering with/without --force and "tag <name>" format
1000-
git tag -f testTag HEAD~ &&
1001-
test_must_fail git push ../child2 tag testTag &&
1002-
git push --force ../child2 tag testTag
1003-
)
1004-
'
968+
test_force_push_tag () {
969+
tag_type_description=$1
970+
tag_args=$2
971+
972+
test_expect_success 'force pushing required to update lightweight tag' "
973+
mk_test testrepo heads/master &&
974+
mk_child testrepo child1 &&
975+
mk_child testrepo child2 &&
976+
(
977+
cd child1 &&
978+
git tag testTag &&
979+
git push ../child2 testTag &&
980+
>file1 &&
981+
git add file1 &&
982+
git commit -m 'file1' &&
983+
git tag $tag_args testTag &&
984+
test_must_fail git push ../child2 testTag &&
985+
git push --force ../child2 testTag &&
986+
git tag $tag_args testTag HEAD~ &&
987+
test_must_fail git push ../child2 testTag &&
988+
git push --force ../child2 testTag &&
989+
990+
# Clobbering without + in refspec needs --force
991+
git tag -f testTag &&
992+
test_must_fail git push ../child2 'refs/tags/*:refs/tags/*' &&
993+
git push --force ../child2 'refs/tags/*:refs/tags/*' &&
994+
995+
# Clobbering with + in refspec does not need --force
996+
git tag -f testTag HEAD~ &&
997+
git push ../child2 '+refs/tags/*:refs/tags/*' &&
998+
999+
# Clobbering with --no-force still obeys + in refspec
1000+
git tag -f testTag &&
1001+
git push --no-force ../child2 '+refs/tags/*:refs/tags/*' &&
1002+
1003+
# Clobbering with/without --force and 'tag <name>' format
1004+
git tag -f testTag HEAD~ &&
1005+
test_must_fail git push ../child2 tag testTag &&
1006+
git push --force ../child2 tag testTag
1007+
)
1008+
"
1009+
}
1010+
1011+
test_force_push_tag "lightweight tag" "-f"
1012+
test_force_push_tag "annotated tag" "-f -a -m'msg'"
10051013

10061014
test_expect_success 'push --porcelain' '
10071015
mk_empty testrepo &&

0 commit comments

Comments
 (0)