Code

Merge branch 'db/clone-in-c'
[git.git] / t / t5516-fetch-push.sh
index 793ffc6600202431193887a12981105c099d40df..c5c59335f36d0d8f6a26ee606fd605e74e2d1e33 100755 (executable)
@@ -103,9 +103,9 @@ test_expect_success 'fetch with wildcard' '
 test_expect_success 'fetch with insteadOf' '
        mk_empty &&
        (
-               TRASH=$(pwd) &&
+               TRASH=$(pwd)/ &&
                cd testrepo &&
-               git config url./$TRASH/.insteadOf trash/
+               git config "url.$TRASH.insteadOf" trash/ &&
                git config remote.up.url trash/. &&
                git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
                git fetch up &&
@@ -145,8 +145,8 @@ test_expect_success 'push with wildcard' '
 
 test_expect_success 'push with insteadOf' '
        mk_empty &&
-       TRASH=$(pwd) &&
-       git config url./$TRASH/.insteadOf trash/ &&
+       TRASH="$(pwd)/" &&
+       git config "url./$TRASH/.insteadOf" trash/ &&
        git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
        (
                cd testrepo &&
@@ -165,6 +165,47 @@ test_expect_success 'push with matching heads' '
 
 '
 
+test_expect_success 'push with matching heads on the command line' '
+
+       mk_test heads/master &&
+       git push testrepo : &&
+       check_push_result $the_commit heads/master
+
+'
+
+test_expect_success 'failed (non-fast-forward) push with matching heads' '
+
+       mk_test heads/master &&
+       git push testrepo : &&
+       git commit --amend -massaged &&
+       ! git push testrepo &&
+       check_push_result $the_commit heads/master &&
+       git reset --hard $the_commit
+
+'
+
+test_expect_success 'push --force with matching heads' '
+
+       mk_test heads/master &&
+       git push testrepo : &&
+       git commit --amend -massaged &&
+       git push --force testrepo &&
+       ! check_push_result $the_commit heads/master &&
+       git reset --hard $the_commit
+
+'
+
+test_expect_success 'push with matching heads and forced update' '
+
+       mk_test heads/master &&
+       git push testrepo : &&
+       git commit --amend -massaged &&
+       git push testrepo +: &&
+       ! check_push_result $the_commit heads/master &&
+       git reset --hard $the_commit
+
+'
+
 test_expect_success 'push with no ambiguity (1)' '
 
        mk_test heads/master &&
@@ -209,19 +250,7 @@ test_expect_success 'push with weak ambiguity (2)' '
 
 '
 
-test_expect_success 'push with ambiguity (1)' '
-
-       mk_test remotes/origin/master remotes/frotz/master &&
-       if git push testrepo master:master
-       then
-               echo "Oops, should have failed"
-               false
-       else
-               check_push_result $the_first_commit remotes/origin/master remotes/frotz/master
-       fi
-'
-
-test_expect_success 'push with ambiguity (2)' '
+test_expect_success 'push with ambiguity' '
 
        mk_test heads/frotz tags/frotz &&
        if git push testrepo master:frotz
@@ -285,6 +314,37 @@ test_expect_success 'push with colon-less refspec (4)' '
 
 '
 
+test_expect_success 'push head with non-existant, incomplete dest' '
+
+       mk_test &&
+       git push testrepo master:branch &&
+       check_push_result $the_commit heads/branch
+
+'
+
+test_expect_success 'push tag with non-existant, incomplete dest' '
+
+       mk_test &&
+       git tag -f v1.0 &&
+       git push testrepo v1.0:tag &&
+       check_push_result $the_commit tags/tag
+
+'
+
+test_expect_success 'push sha1 with non-existant, incomplete dest' '
+
+       mk_test &&
+       test_must_fail git push testrepo `git rev-parse master`:foo
+
+'
+
+test_expect_success 'push ref expression with non-existant, incomplete dest' '
+
+       mk_test &&
+       test_must_fail git push testrepo master^:branch
+
+'
+
 test_expect_success 'push with HEAD' '
 
        mk_test heads/master &&
@@ -323,6 +383,15 @@ test_expect_success 'push with +HEAD' '
 
 '
 
+test_expect_success 'push HEAD with non-existant, incomplete dest' '
+
+       mk_test &&
+       git checkout master &&
+       git push testrepo HEAD:branch &&
+       check_push_result $the_commit heads/branch
+
+'
+
 test_expect_success 'push with config remote.*.push = HEAD' '
 
        mk_test heads/local &&