Skip to content

Commit e980765

Browse files
phordpeff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 8c7a786 commit e980765

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

git-pull.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ test true = "$rebase" && {
200200
require_clean_work_tree "pull with rebase" "Please commit or stash them."
201201
fi
202202
oldremoteref= &&
203+
test -n "$curr_branch" &&
203204
. git-parse-remote &&
204205
remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
205206
oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&

0 commit comments

Comments
 (0)