Skip to content

Commit

Permalink
t/t2021-checkout-last: "checkout -" should work after a rebase finishes
Browse files Browse the repository at this point in the history
  $ git checkout -

does not work as expected after a rebase.  This is because the
reflog records "checkout" made by "rebase" as its implementation
detail the same way as end-user initiated "checkout", and makes it
count as the branch that was previously checked out.

Add four failing tests documenting this bug: two for a normal rebase,
and another two for an interactive rebase.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ramkumar Ramachandra authored and Junio C Hamano committed Jun 17, 2013
1 parent ce23d49 commit 89f2fea
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions t/t2012-checkout-last.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,38 @@ test_expect_success 'master...' '
test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"
'

test_expect_failure '"checkout -" works after a rebase A' '
git checkout master &&
git checkout other &&
git rebase master &&
git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
'

test_expect_failure '"checkout -" works after a rebase A B' '
git branch moodle master~1 &&
git checkout master &&
git checkout other &&
git rebase master moodle &&
git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
'

test_expect_failure '"checkout -" works after a rebase -i A' '
git checkout master &&
git checkout other &&
git rebase -i master &&
git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
'

test_expect_failure '"checkout -" works after a rebase -i A B' '
git branch foodle master~1 &&
git checkout master &&
git checkout other &&
git rebase master foodle &&
git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
'

test_done

0 comments on commit 89f2fea

Please sign in to comment.