Skip to content

Commit 42a6274

Browse files
committed
Merge branch 'ab/fetch-tags-noclobber'
Test and doc clean-ups. * ab/fetch-tags-noclobber: pull doc: fix a long-standing grammar error fetch tests: correct a comment "remove it" -> "remove them" push tests: assert re-pushing annotated tags push tests: add more testing for forced tag pushing push tests: fix logic error in "push" test assertion push tests: remove redundant 'git push' invocation fetch tests: change "Tag" test tag to "testTag"
2 parents 03e904c + b81699a commit 42a6274

File tree

3 files changed

+47
-22
lines changed

3 files changed

+47
-22
lines changed

Documentation/pull-fetch-param.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ name.
3333
it requests fetching everything up to the given tag.
3434
+
3535
The remote ref that matches <src>
36-
is fetched, and if <dst> is not empty string, the local
36+
is fetched, and if <dst> is not an empty string, the local
3737
ref that matches it is fast-forwarded using <src>.
3838
If the optional plus `+` is used, the local ref
3939
is updated even if it does not result in a fast-forward

t/t5510-fetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ test_configured_prune_type () {
648648
git rev-parse --verify refs/tags/newtag
649649
) &&
650650
651-
# now remove it
651+
# now remove them
652652
git branch -d newbranch &&
653653
git tag -d newtag &&
654654

t/t5516-fetch-push.sh

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

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'"
9881013

9891014
test_expect_success 'push --porcelain' '
9901015
mk_empty testrepo &&

0 commit comments

Comments
 (0)