Skip to content

Commit a6dbf88

Browse files
committed
pull: Clarify "helpful" message for another corner case
When the remote branch we asked for merging did not exist in the set of fetched refs, we unconditionally hinted that it was because of lack of configuration. It is not necessarily so, and risks sending users for a wild goose chase. Make sure to check if that is indeed the case before telling a wild guess to the user. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3ddcb19 commit a6dbf88

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-pull.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ error_on_no_merge_candidates () {
8989
done
9090

9191
curr_branch=${curr_branch#refs/heads/}
92+
upstream=$(git config "branch.$curr_branch.merge")
9293

9394
if [ -z "$curr_branch" ]; then
9495
echo "You are not currently on a branch, so I cannot use any"
9596
echo "'branch.<branchname>.merge' in your configuration file."
9697
echo "Please specify which branch you want to merge on the command"
9798
echo "line and try again (e.g. 'git pull <repository> <refspec>')."
9899
echo "See git-pull(1) for details."
99-
else
100+
elif [ -z "$upstream" ]; then
100101
echo "You asked me to pull without telling me which branch you"
101102
echo "want to merge with, and 'branch.${curr_branch}.merge' in"
102103
echo "your configuration file does not tell me either. Please"
@@ -114,6 +115,10 @@ error_on_no_merge_candidates () {
114115
echo " remote.<nickname>.fetch = <refspec>"
115116
echo
116117
echo "See git-config(1) for details."
118+
else
119+
echo "Your configuration specifies to merge the ref"
120+
echo "'${upstream#refs/heads/}' from the remote, but no such ref"
121+
echo "was fetched."
117122
fi
118123
exit 1
119124
}

0 commit comments

Comments
 (0)