git-pull: Avoid merge-base on detached head

git pull --rebase does some clever tricks to find the base for $upstream, but it forgets that we may not have any branch at all. When this happens, git merge-base reports its "usage" help in the middle of an otherwise successful rebase operation, because git-merge is called with one too few parameters. Since we do not need the merge-base trick in the case of a detached HEAD, detect this condition and bypass the clever trick and the usage noise. Signed-off-by: Phil Hord <hordp@cisco.com> Signed-off-by: Jeff King <peff@peff.net>

Phil Hord committed Oct 23, 2012 at 16:39 UTC e980765c59c173e9a10ce1069c763645b87fd50c
1 file changed +1
git-pull.sh
+1
@@ -200,6 +200,7 @@ test true = "$rebase" && {
200 require_clean_work_tree "pull with rebase" "Please commit or stash them."
201 fi
202 oldremoteref= &&
203 + test -n "$curr_branch" &&
204 . git-parse-remote &&
205 remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
206 oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&