@@ -835,32 +835,42 @@ test_expect_success 'branch from tag w/--track causes failure' '
835835'
836836
837837test_expect_success ' --set-upstream-to fails on multiple branches' '
838- test_must_fail git branch --set-upstream-to master a b c
838+ echo "fatal: too many arguments to set new upstream" >expect &&
839+ test_must_fail git branch --set-upstream-to master a b c 2>err &&
840+ test_i18ncmp expect err
839841'
840842
841843test_expect_success ' --set-upstream-to fails on detached HEAD' '
842844 git checkout HEAD^{} &&
843- test_must_fail git branch --set-upstream-to master &&
844- git checkout -
845+ test_when_finished git checkout - &&
846+ echo "fatal: could not set upstream of HEAD to master when it does not point to any branch." >expect &&
847+ test_must_fail git branch --set-upstream-to master 2>err &&
848+ test_i18ncmp expect err
845849'
846850
847851test_expect_success ' --set-upstream-to fails on a missing dst branch' '
848- test_must_fail git branch --set-upstream-to master does-not-exist
852+ echo "fatal: branch ' " '" ' does-not-exist' " '" ' does not exist" >expect &&
853+ test_must_fail git branch --set-upstream-to master does-not-exist 2>err &&
854+ test_i18ncmp expect err
849855'
850856
851857test_expect_success ' --set-upstream-to fails on a missing src branch' '
852- test_must_fail git branch --set-upstream-to does-not-exist master
858+ test_must_fail git branch --set-upstream-to does-not-exist master 2>err &&
859+ test_i18ngrep "the requested upstream branch ' " '" ' does-not-exist' " '" ' does not exist" err
853860'
854861
855862test_expect_success ' --set-upstream-to fails on a non-ref' '
856- test_must_fail git branch --set-upstream-to HEAD^{}
863+ echo "fatal: Cannot setup tracking information; starting point ' " '" ' HEAD^{}' " '" ' is not a branch." >expect &&
864+ test_must_fail git branch --set-upstream-to HEAD^{} 2>err &&
865+ test_i18ncmp expect err
857866'
858867
859868test_expect_success ' --set-upstream-to fails on locked config' '
860869 test_when_finished "rm -f .git/config.lock" &&
861870 >.git/config.lock &&
862871 git branch locked &&
863- test_must_fail git branch --set-upstream-to locked
872+ test_must_fail git branch --set-upstream-to locked 2>err &&
873+ test_i18ngrep "could not lock config file .git/config: File exists" err
864874'
865875
866876test_expect_success ' use --set-upstream-to modify HEAD' '
@@ -881,14 +891,17 @@ test_expect_success 'use --set-upstream-to modify a particular branch' '
881891'
882892
883893test_expect_success ' --unset-upstream should fail if given a non-existent branch' '
884- test_must_fail git branch --unset-upstream i-dont-exist
894+ echo "fatal: Branch ' " '" ' i-dont-exist' " '" ' has no upstream information" >expect &&
895+ test_must_fail git branch --unset-upstream i-dont-exist 2>err &&
896+ test_i18ncmp expect err
885897'
886898
887899test_expect_success ' --unset-upstream should fail if config is locked' '
888900 test_when_finished "rm -f .git/config.lock" &&
889901 git branch --set-upstream-to locked &&
890902 >.git/config.lock &&
891- test_must_fail git branch --unset-upstream
903+ test_must_fail git branch --unset-upstream 2>err &&
904+ test_i18ngrep "could not lock config file .git/config: File exists" err
892905'
893906
894907test_expect_success ' test --unset-upstream on HEAD' '
@@ -900,17 +913,23 @@ test_expect_success 'test --unset-upstream on HEAD' '
900913 test_must_fail git config branch.master.remote &&
901914 test_must_fail git config branch.master.merge &&
902915 # fail for a branch without upstream set
903- test_must_fail git branch --unset-upstream
916+ echo "fatal: Branch ' " '" ' master' " '" ' has no upstream information" >expect &&
917+ test_must_fail git branch --unset-upstream 2>err &&
918+ test_i18ncmp expect err
904919'
905920
906921test_expect_success ' --unset-upstream should fail on multiple branches' '
907- test_must_fail git branch --unset-upstream a b c
922+ echo "fatal: too many arguments to unset upstream" >expect &&
923+ test_must_fail git branch --unset-upstream a b c 2>err &&
924+ test_i18ncmp expect err
908925'
909926
910927test_expect_success ' --unset-upstream should fail on detached HEAD' '
911928 git checkout HEAD^{} &&
912- test_must_fail git branch --unset-upstream &&
913- git checkout -
929+ test_when_finished git checkout - &&
930+ echo "fatal: could not unset upstream of HEAD when it does not point to any branch." >expect &&
931+ test_must_fail git branch --unset-upstream 2>err &&
932+ test_i18ncmp expect err
914933'
915934
916935test_expect_success ' test --unset-upstream on a particular branch' '
0 commit comments