@@ -965,26 +965,51 @@ test_expect_success 'push into aliased refs (inconsistent)' '
965
965
)
966
966
'
967
967
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
- git push ../child2 Tag &&
977
- >file1 &&
978
- git add file1 &&
979
- git commit -m "file1" &&
980
- git tag -f Tag &&
981
- test_must_fail git push ../child2 Tag &&
982
- git push --force ../child2 Tag &&
983
- git tag -f Tag &&
984
- test_must_fail git push ../child2 Tag HEAD~ &&
985
- git push --force ../child2 Tag
986
- )
987
- '
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'"
988
1013
989
1014
test_expect_success ' push --porcelain' '
990
1015
mk_empty testrepo &&
0 commit comments