checkout: avoid unnecessary match_pathspec calls
[gitweb.git] / t / t5516-fetch-push.sh
index 2b26ecebf7d46e47c79856b0046d045c883527eb..6fd125aecf128a6c4a2ae8b986d5a311c6d0c133 100755 (executable)
@@ -950,27 +950,6 @@ test_expect_success 'push requires --force to update lightweight tag' '
        )
 '
 
-test_expect_success 'push requires --force to update annotated tag' '
-       mk_test heads/master &&
-       mk_child child1 &&
-       mk_child child2 &&
-       (
-               cd child1 &&
-               git tag -a -m "message 1" Tag &&
-               git push ../child2 Tag:refs/tmp/Tag &&
-               git push ../child2 Tag:refs/tmp/Tag &&
-               >file1 &&
-               git add file1 &&
-               git commit -m "file1" &&
-               git tag -f -a -m "message 2" Tag &&
-               test_must_fail git push ../child2 Tag:refs/tmp/Tag &&
-               git push --force ../child2 Tag:refs/tmp/Tag &&
-               git tag -f -a -m "message 3" Tag HEAD~ &&
-               test_must_fail git push ../child2 Tag:refs/tmp/Tag &&
-               git push --force ../child2 Tag:refs/tmp/Tag
-       )
-'
-
 test_expect_success 'push --porcelain' '
        mk_empty &&
        echo >.git/foo  "To testrepo" &&
@@ -1064,4 +1043,38 @@ do
        '
 done
 
+test_expect_success 'fetch exact SHA1' '
+       mk_test heads/master hidden/one &&
+       git push testrepo master:refs/hidden/one &&
+       (
+               cd testrepo &&
+               git config transfer.hiderefs refs/hidden
+       ) &&
+       check_push_result $the_commit hidden/one &&
+
+       mk_child child &&
+       (
+               cd child &&
+
+               # make sure $the_commit does not exist here
+               git repack -a -d &&
+               git prune &&
+               test_must_fail git cat-file -t $the_commit &&
+
+               # fetching the hidden object should fail by default
+               test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy &&
+               test_must_fail git rev-parse --verify refs/heads/copy &&
+
+               # the server side can allow it to succeed
+               (
+                       cd ../testrepo &&
+                       git config uploadpack.allowtipsha1inwant true
+               ) &&
+
+               git fetch -v ../testrepo $the_commit:refs/heads/copy &&
+               result=$(git rev-parse --verify refs/heads/copy) &&
+               test "$the_commit" = "$result"
+       )
+'
+
 test_done