match-trees: use hashcpy to splice trees
[gitweb.git] / t / t5516-fetch-push.sh
index 539c25aadafdcf6aa9fbcce0988631702d3fb02d..37e8e80893dad130c5c00882796047417aae115b 100755 (executable)
@@ -95,7 +95,7 @@ mk_child() {
 
 check_push_result () {
        test $# -ge 3 ||
-       error "bug in the test script: check_push_result requires at least 3 parameters"
+       BUG "check_push_result requires at least 3 parameters"
 
        repo_name="$1"
        shift
@@ -969,7 +969,7 @@ test_force_push_tag () {
        tag_type_description=$1
        tag_args=$2
 
-       test_expect_success 'force pushing required to update lightweight tag' "
+       test_expect_success "force pushing required to update $tag_type_description" "
                mk_test testrepo heads/master &&
                mk_child testrepo child1 &&
                mk_child testrepo child2 &&
@@ -1009,7 +1009,32 @@ test_force_push_tag () {
 }
 
 test_force_push_tag "lightweight tag" "-f"
-test_force_push_tag "annotated tag" "-f -a -m'msg'"
+test_force_push_tag "annotated tag" "-f -a -m'tag message'"
+
+test_force_fetch_tag () {
+       tag_type_description=$1
+       tag_args=$2
+
+       test_expect_success "fetch will not clobber an existing $tag_type_description without --force" "
+               mk_test testrepo heads/master &&
+               mk_child testrepo child1 &&
+               mk_child testrepo child2 &&
+               (
+                       cd testrepo &&
+                       git tag testTag &&
+                       git -C ../child1 fetch origin tag testTag &&
+                       >file1 &&
+                       git add file1 &&
+                       git commit -m 'file1' &&
+                       git tag $tag_args testTag &&
+                       test_must_fail git -C ../child1 fetch origin tag testTag &&
+                       git -C ../child1 fetch origin '+refs/tags/*:refs/tags/*'
+               )
+       "
+}
+
+test_force_fetch_tag "lightweight tag" "-f"
+test_force_fetch_tag "annotated tag" "-f -a -m'tag message'"
 
 test_expect_success 'push --porcelain' '
        mk_empty testrepo &&
@@ -1552,7 +1577,13 @@ test_expect_success 'receive.denyCurrentBranch = updateInstead' '
                test $(git -C .. rev-parse master) = $(git rev-parse HEAD) &&
                git diff --quiet &&
                git diff --cached --quiet
-       )
+       ) &&
+
+       # (6) updateInstead intervened by fast-forward check
+       test_must_fail git push void master^:master &&
+       test $(git -C void rev-parse HEAD) = $(git rev-parse master) &&
+       git -C void diff --quiet &&
+       git -C void diff --cached --quiet
 '
 
 test_expect_success 'updateInstead with push-to-checkout hook' '