965
)
966
'
967
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'"
1013
1014
test_expect_success 'push --porcelain' '
1015
mk_empty testrepo &&