Skip to content

Commit 941a7ba

Browse files
avargitster
authored andcommitted
push tests: add more testing for forced tag pushing
Improve the tests added in dbfeddb ("push: require force for refs under refs/tags/", 2012-11-29) to assert that the same behavior applies various other combinations of command-line option and refspecs. Supplying either "+" in refspec or "--force" is sufficient to clobber the reference. With --no-force we still pay attention to "+" in the refspec, and vice-versa with clobbering kicking in if there's no "+" in the refspec but "+" is given. This is consistent with how refspecs work for branches, where either "+" or "--force" will enable clobbering, with neither taking priority over the other. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25f74f5 commit 941a7ba

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

t/t5516-fetch-push.sh

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

968-
test_expect_success 'push requires --force to update lightweight tag' '
968+
test_expect_success 'force pushing required to update lightweight tag' '
969969
mk_test testrepo heads/master &&
970970
mk_child testrepo child1 &&
971971
mk_child testrepo child2 &&
@@ -981,7 +981,25 @@ test_expect_success 'push requires --force to update lightweight tag' '
981981
git push --force ../child2 testTag &&
982982
git tag -f testTag HEAD~ &&
983983
test_must_fail git push ../child2 testTag &&
984-
git push --force ../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
9851003
)
9861004
'
9871005

0 commit comments

Comments
 (0)