pull: clarify advice for the unconfigured error case
When pull --rebase fails because it cannot find what branch to merge against, the error message implies we are trying to merge. Say "rebase against" instead of "merge with" to avoid confusion. The configuration suggested to remedy the situation uses a confusing syntax, with variables specified in the dotted form accepted by 'git config' but separated from their values by the '=' delimiter used by config files. Since the user will have to edit this output anyway, it is more helpful to provide a config file snippet to paste into an editor and modify. Signed-off-by: Jan Krüger <jk@jk.gs> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jan Krüger committed
Nov 27, 2009 at 08:17 UTC
995fc2f7e17fab8dd59f31f25870a0823cdb6f27
1 file changed
+33
-15
git-pull.sh
+33
-15
@@ -88,45 +88,63 @@ error_on_no_merge_candidates () {
88
esac
89
done
90
91
+ if test true = "$rebase"
92
+ then
93
+ op_type=rebase
94
+ op_prep=against
95
+ else
96
+ op_type=merge
97
+ op_prep=with
98
+ fi
99
+
100
curr_branch=${curr_branch#refs/heads/}
101
upstream=$(git config "branch.$curr_branch.merge")
102
remote=$(git config "branch.$curr_branch.remote")
103
104
if [ $# -gt 1 ]; then
96
- echo "There are no candidates for merging in the refs that you just fetched."
105
+ if [ "$rebase" = true ]; then
106
+ printf "There is no candidate for rebasing against "
107
+ else
108
+ printf "There are no candidates for merging "
109
+ fi
110
+ echo "among the refs that you just fetched."
111
echo "Generally this means that you provided a wildcard refspec which had no"
112
echo "matches on the remote end."
113
elif [ $# -gt 0 ] && [ "$1" != "$remote" ]; then
114
echo "You asked to pull from the remote '$1', but did not specify"
101
- echo "a branch to merge. Because this is not the default configured remote"
115
+ echo "a branch. Because this is not the default configured remote"
116
echo "for your current branch, you must specify a branch on the command line."
117
elif [ -z "$curr_branch" ]; then
118
echo "You are not currently on a branch, so I cannot use any"
119
echo "'branch.<branchname>.merge' in your configuration file."
106
- echo "Please specify which branch you want to merge on the command"
120
+ echo "Please specify which remote branch you want to use on the command"
121
echo "line and try again (e.g. 'git pull <repository> <refspec>')."
122
echo "See git-pull(1) for details."
123
elif [ -z "$upstream" ]; then
124
echo "You asked me to pull without telling me which branch you"
111
- echo "want to merge with, and 'branch.${curr_branch}.merge' in"
112
- echo "your configuration file does not tell me either. Please"
113
- echo "specify which branch you want to merge on the command line and"
125
+ echo "want to $op_type $op_prep, and 'branch.${curr_branch}.merge' in"
126
+ echo "your configuration file does not tell me, either. Please"
127
+ echo "specify which branch you want to use on the command line and"
128
echo "try again (e.g. 'git pull <repository> <refspec>')."
129
echo "See git-pull(1) for details."
130
echo
117
- echo "If you often merge with the same branch, you may want to"
118
- echo "configure the following variables in your configuration"
119
- echo "file:"
131
+ echo "If you often $op_type $op_prep the same branch, you may want to"
132
+ echo "use something like the following in your configuration file:"
133
+ echo
134
+ echo " [branch \"${curr_branch}\"]"
135
+ echo " remote = <nickname>"
136
+ echo " merge = <remote-ref>"
137
+ test rebase = "$op_type" &&
138
+ echo " rebase = true"
139
echo
121
- echo " branch.${curr_branch}.remote = <nickname>"
122
- echo " branch.${curr_branch}.merge = <remote-ref>"
123
- echo " remote.<nickname>.url = <url>"
124
- echo " remote.<nickname>.fetch = <refspec>"
140
+ echo " [remote \"<nickname>\"]"
141
+ echo " url = <url>"
142
+ echo " fetch = <refspec>"
143
echo
144
echo "See git-config(1) for details."
145
else
128
- echo "Your configuration specifies to merge the ref '${upstream#refs/heads/}' from the"
129
- echo "remote, but no such ref was fetched."
146
+ echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
147
+ echo "from the remote, but no such ref was fetched."
148
fi
149
exit 1
150
}