t3200: test --set-upstream-to with bogus refs
authorJeff King <peff@peff.net>
Tue, 2 Apr 2013 19:02:53 +0000 (15:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Apr 2013 23:14:06 +0000 (16:14 -0700)
These tests pass with the current code, but let's make sure
we don't accidentally break the behavior in the future.

Note that our tests expect failure when we try to set the
upstream to or from a missing branch. Technically we are
just munging config here, so we do not need the refs to
exist. But seeing that they do exist is a good check that
the user has not made a typo.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3200-branch.sh
index b08c9f22951bf447cc769c043a165d087fa5e38d..09f65f8358a70a85c4cf6fdfb4506f2edc19e6d1 100755 (executable)
@@ -409,6 +409,18 @@ test_expect_success '--set-upstream-to fails on detached HEAD' '
        git checkout -
 '
 
+test_expect_success '--set-upstream-to fails on a missing dst branch' '
+       test_must_fail git branch --set-upstream-to master does-not-exist
+'
+
+test_expect_success '--set-upstream-to fails on a missing src branch' '
+       test_must_fail git branch --set-upstream-to does-not-exist master
+'
+
+test_expect_success '--set-upstream-to fails on a non-ref' '
+       test_must_fail git branch --set-upstream-to HEAD^{}
+'
+
 test_expect_success 'use --set-upstream-to modify HEAD' '
        test_config branch.master.remote foo &&
        test_config branch.master.merge foo &&