Skip to content

Commit 8a3e5ec

Browse files
peffgitster
authored andcommitted
t3200: test --set-upstream-to with bogus refs
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 961c512 commit 8a3e5ec

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

t/t3200-branch.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,18 @@ test_expect_success '--set-upstream-to fails on detached HEAD' '
409409
git checkout -
410410
'
411411

412+
test_expect_success '--set-upstream-to fails on a missing dst branch' '
413+
test_must_fail git branch --set-upstream-to master does-not-exist
414+
'
415+
416+
test_expect_success '--set-upstream-to fails on a missing src branch' '
417+
test_must_fail git branch --set-upstream-to does-not-exist master
418+
'
419+
420+
test_expect_success '--set-upstream-to fails on a non-ref' '
421+
test_must_fail git branch --set-upstream-to HEAD^{}
422+
'
423+
412424
test_expect_success 'use --set-upstream-to modify HEAD' '
413425
test_config branch.master.remote foo &&
414426
test_config branch.master.merge foo &&

0 commit comments

Comments
 (0)