Skip to content

Commit

Permalink
git-pull: Avoid merge-base on detached head
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Phil Hord authored and Jeff King committed Oct 25, 2012
1 parent 8c7a786 commit e980765
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions git-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ test true = "$rebase" && {
require_clean_work_tree "pull with rebase" "Please commit or stash them."
fi
oldremoteref= &&
test -n "$curr_branch" &&
. git-parse-remote &&
remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
Expand Down

0 comments on commit e980765

Please sign in to comment.