Code

merge-base-many: add trivial tests based on the documentation
[git.git] / t / t5516-fetch-push.sh
index 352e83bdc62b2971c89a12c42fb202836b36c744..f0030ad00e4a6478fcb3ccfc503e576bd58003bd 100755 (executable)
@@ -100,6 +100,23 @@ test_expect_success 'fetch with wildcard' '
        )
 '
 
+test_expect_success 'fetch with insteadOf' '
+       mk_empty &&
+       (
+               TRASH=$(pwd)/ &&
+               cd testrepo &&
+               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 &&
+
+               r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+               test "z$r" = "z$the_commit" &&
+
+               test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+       )
+'
+
 test_expect_success 'push without wildcard' '
        mk_empty &&
 
@@ -126,6 +143,20 @@ test_expect_success 'push with wildcard' '
        )
 '
 
+test_expect_success 'push with insteadOf' '
+       mk_empty &&
+       TRASH="$(pwd)/" &&
+       git config "url.$TRASH.insteadOf" trash/ &&
+       git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
+       (
+               cd testrepo &&
+               r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+               test "z$r" = "z$the_commit" &&
+
+               test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+       )
+'
+
 test_expect_success 'push with matching heads' '
 
        mk_test heads/master &&
@@ -134,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 &&
+       test_must_fail 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 &&
@@ -242,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 &&
@@ -259,6 +362,58 @@ test_expect_success 'push with HEAD nonexisting at remote' '
        check_push_result $the_commit heads/local
 '
 
+test_expect_success 'push with +HEAD' '
+
+       mk_test heads/master &&
+       git checkout master &&
+       git branch -D local &&
+       git checkout -b local &&
+       git push testrepo master local &&
+       check_push_result $the_commit heads/master &&
+       check_push_result $the_commit heads/local &&
+
+       # Without force rewinding should fail
+       git reset --hard HEAD^ &&
+       test_must_fail git push testrepo HEAD &&
+       check_push_result $the_commit heads/local &&
+
+       # With force rewinding should succeed
+       git push testrepo +HEAD &&
+       check_push_result $the_first_commit heads/local
+
+'
+
+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 &&
+       git checkout master &&
+       git branch -f local $the_commit &&
+       (
+               cd testrepo &&
+               git checkout local &&
+               git reset --hard $the_first_commit
+       ) &&
+       git config remote.there.url testrepo &&
+       git config remote.there.push HEAD &&
+       git config branch.master.remote there &&
+       git push &&
+       check_push_result $the_commit heads/master &&
+       check_push_result $the_first_commit heads/local
+'
+
+# clean up the cruft left with the previous one
+git config --remove-section remote.there
+git config --remove-section branch.master
+
 test_expect_success 'push with dry-run' '
 
        mk_test heads/master &&
@@ -293,7 +448,7 @@ test_expect_success 'push does not update local refs on failure' '
        git clone parent child &&
        (cd child &&
                echo two >foo && git commit -a -m two &&
-               ! git push &&
+               test_must_fail git push &&
                test $(git rev-parse master) != \
                        $(git rev-parse remotes/origin/master))
 
@@ -304,7 +459,7 @@ test_expect_success 'allow deleting an invalid remote ref' '
        pwd &&
        rm -f testrepo/.git/objects/??/* &&
        git push testrepo :refs/heads/master &&
-       (cd testrepo && ! git rev-parse --verify refs/heads/master)
+       (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
 
 '