push tests: assert re-pushing annotated tags
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 31 Jul 2018 13:07:13 +0000 (13:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 31 Jul 2018 16:25:25 +0000 (09:25 -0700)
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5516-fetch-push.sh
index 4bd533dd48ef00ec3627b3f02410bbb504a13e2e..1331a8de082008b2712e62edc7952f565aeefccf 100755 (executable)
@@ -965,43 +965,51 @@ test_expect_success 'push into aliased refs (inconsistent)' '
        )
 '
 
-test_expect_success 'force pushing required to update lightweight tag' '
-       mk_test testrepo heads/master &&
-       mk_child testrepo child1 &&
-       mk_child testrepo child2 &&
-       (
-               cd child1 &&
-               git tag testTag &&
-               git push ../child2 testTag &&
-               >file1 &&
-               git add file1 &&
-               git commit -m "file1" &&
-               git tag -f testTag &&
-               test_must_fail git push ../child2 testTag &&
-               git push --force ../child2 testTag &&
-               git tag -f testTag HEAD~ &&
-               test_must_fail git push ../child2 testTag &&
-               git push --force ../child2 testTag &&
-
-               # Clobbering without + in refspec needs --force
-               git tag -f testTag &&
-               test_must_fail git push ../child2 "refs/tags/*:refs/tags/*" &&
-               git push --force ../child2 "refs/tags/*:refs/tags/*" &&
-
-               # Clobbering with + in refspec does not need --force
-               git tag -f testTag HEAD~ &&
-               git push ../child2 "+refs/tags/*:refs/tags/*" &&
-
-               # Clobbering with --no-force still obeys + in refspec
-               git tag -f testTag &&
-               git push --no-force ../child2 "+refs/tags/*:refs/tags/*" &&
-
-               # Clobbering with/without --force and "tag <name>" format
-               git tag -f testTag HEAD~ &&
-               test_must_fail git push ../child2 tag testTag &&
-               git push --force ../child2 tag testTag
-       )
-'
+test_force_push_tag () {
+       tag_type_description=$1
+       tag_args=$2
+
+       test_expect_success 'force pushing required to update lightweight tag' "
+               mk_test testrepo heads/master &&
+               mk_child testrepo child1 &&
+               mk_child testrepo child2 &&
+               (
+                       cd child1 &&
+                       git tag testTag &&
+                       git push ../child2 testTag &&
+                       >file1 &&
+                       git add file1 &&
+                       git commit -m 'file1' &&
+                       git tag $tag_args testTag &&
+                       test_must_fail git push ../child2 testTag &&
+                       git push --force ../child2 testTag &&
+                       git tag $tag_args testTag HEAD~ &&
+                       test_must_fail git push ../child2 testTag &&
+                       git push --force ../child2 testTag &&
+
+                       # Clobbering without + in refspec needs --force
+                       git tag -f testTag &&
+                       test_must_fail git push ../child2 'refs/tags/*:refs/tags/*' &&
+                       git push --force ../child2 'refs/tags/*:refs/tags/*' &&
+
+                       # Clobbering with + in refspec does not need --force
+                       git tag -f testTag HEAD~ &&
+                       git push ../child2 '+refs/tags/*:refs/tags/*' &&
+
+                       # Clobbering with --no-force still obeys + in refspec
+                       git tag -f testTag &&
+                       git push --no-force ../child2 '+refs/tags/*:refs/tags/*' &&
+
+                       # Clobbering with/without --force and 'tag <name>' format
+                       git tag -f testTag HEAD~ &&
+                       test_must_fail git push ../child2 tag testTag &&
+                       git push --force ../child2 tag testTag
+               )
+       "
+}
+
+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 &&