@@ -835,32 +835,42 @@ test_expect_success 'branch from tag w/--track causes failure' '
835
835
'
836
836
837
837
test_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
839
841
'
840
842
841
843
test_expect_success ' --set-upstream-to fails on detached HEAD' '
842
844
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
845
849
'
846
850
847
851
test_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
849
855
'
850
856
851
857
test_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
853
860
'
854
861
855
862
test_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
857
866
'
858
867
859
868
test_expect_success ' --set-upstream-to fails on locked config' '
860
869
test_when_finished "rm -f .git/config.lock" &&
861
870
>.git/config.lock &&
862
871
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
864
874
'
865
875
866
876
test_expect_success ' use --set-upstream-to modify HEAD' '
@@ -881,14 +891,17 @@ test_expect_success 'use --set-upstream-to modify a particular branch' '
881
891
'
882
892
883
893
test_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
885
897
'
886
898
887
899
test_expect_success ' --unset-upstream should fail if config is locked' '
888
900
test_when_finished "rm -f .git/config.lock" &&
889
901
git branch --set-upstream-to locked &&
890
902
>.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
892
905
'
893
906
894
907
test_expect_success ' test --unset-upstream on HEAD' '
@@ -900,17 +913,23 @@ test_expect_success 'test --unset-upstream on HEAD' '
900
913
test_must_fail git config branch.master.remote &&
901
914
test_must_fail git config branch.master.merge &&
902
915
# 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
904
919
'
905
920
906
921
test_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
908
925
'
909
926
910
927
test_expect_success ' --unset-upstream should fail on detached HEAD' '
911
928
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
914
933
'
915
934
916
935
test_expect_success ' test --unset-upstream on a particular branch' '
0 commit comments