1022
test_cmp expect err
1023
'
1024
1025
+test_expect_success '--set-upstream-to suggests <remote>/<branch> on slip' '
1026
+ test_when_finished "git remote remove slip-remote" &&
1027
+ git remote add slip-remote . &&
1028
+ git update-ref refs/remotes/slip-remote/slip-feature HEAD &&
1029
+ test_must_fail git branch --set-upstream-to slip-remote slip-feature 2>err &&
1030
+ test_grep "takes a single <remote>/<branch> argument" err &&
1031
+ test_grep "hint: Did you mean to use: git branch --set-upstream-to=slip-remote/slip-feature?" err &&
1032
+ test_must_fail git -c advice.setUpstreamFailure=false \
1033
+ branch --set-upstream-to slip-remote slip-feature 2>err &&
1034
+ test_grep ! "Did you mean" err
1035
+'
1036
+
1037
+test_expect_success '--set-upstream-to does not suggest when no matching remote ref' '
1038
+ test_when_finished "git remote remove slip-remote" &&
1039
+ git remote add slip-remote . &&
1040
+ test_must_fail git branch --set-upstream-to slip-remote no-such-branch 2>err &&
1041
+ test_grep "branch ${SQ}no-such-branch${SQ} does not exist" err &&
1042
+ test_grep ! "Did you mean" err
1043
+'
1044
+
1045
+test_expect_success '--set-upstream-to to a local branch is not mistaken for a slip' '
1046
+ git branch slip-local-upstream &&
1047
+ git branch slip-local-target &&
1048
+ git branch --set-upstream-to=slip-local-upstream slip-local-target 2>err &&
1049
+ test_grep ! "Did you mean" err &&
1050
+ echo refs/heads/slip-local-upstream >expect &&
1051
+ git config branch.slip-local-target.merge >actual &&
1052
+ test_cmp expect actual
1053
+'
1054
+
1055
+test_expect_success '--set-upstream-to slip suggestion keeps a slashed branch name' '
1056
+ test_when_finished "git remote remove slip-remote" &&
1057
+ git remote add slip-remote . &&
1058
+ git update-ref refs/remotes/slip-remote/slip/feature HEAD &&
1059
+ test_must_fail git branch --set-upstream-to slip-remote slip/feature 2>err &&
1060
+ test_grep "hint: Did you mean to use: git branch --set-upstream-to=slip-remote/slip/feature?" err
1061
+'
1062
+
1063
test_expect_success '--set-upstream-to fails on a missing src branch' '
1064
test_must_fail git branch --set-upstream-to does-not-exist main 2>err &&
1065
test_grep "the requested upstream branch '"'"'does-not-exist'"'"' does not exist" err