diff --git a/git-rebase.sh b/git-rebase.sh index 15da926ce0..d6c52e6f90 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -464,7 +464,7 @@ case "$#" in head_name="detached HEAD" branch_name=HEAD ;# detached fi - orig_head=$(git rev-parse --verify "${branch_name}^0") || exit + orig_head=$(git rev-parse --verify HEAD) || exit ;; *) die "BUG: unexpected number of arguments left to parse" diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 1de0ebda25..e6af021c10 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -101,7 +101,14 @@ test_expect_success 'HEAD was detached during rebase' ' test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1}) ' +test_expect_success 'rebase from ambiguous branch name' ' + git checkout -b topic side && + git rebase master +' + test_expect_success 'rebase after merge master' ' + git checkout --detach refs/tags/topic && + git branch -D topic && git reset --hard topic && git merge master && git rebase master &&