Skip to content

Commit 89f2fea

Browse files
artagnongitster
authored andcommitted
t/t2021-checkout-last: "checkout -" should work after a rebase finishes
$ 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce23d49 commit 89f2fea

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

t/t2012-checkout-last.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,38 @@ test_expect_success 'master...' '
116116
test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"
117117
'
118118

119+
test_expect_failure '"checkout -" works after a rebase A' '
120+
git checkout master &&
121+
git checkout other &&
122+
git rebase master &&
123+
git checkout - &&
124+
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
125+
'
126+
127+
test_expect_failure '"checkout -" works after a rebase A B' '
128+
git branch moodle master~1 &&
129+
git checkout master &&
130+
git checkout other &&
131+
git rebase master moodle &&
132+
git checkout - &&
133+
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
134+
'
135+
136+
test_expect_failure '"checkout -" works after a rebase -i A' '
137+
git checkout master &&
138+
git checkout other &&
139+
git rebase -i master &&
140+
git checkout - &&
141+
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
142+
'
143+
144+
test_expect_failure '"checkout -" works after a rebase -i A B' '
145+
git branch foodle master~1 &&
146+
git checkout master &&
147+
git checkout other &&
148+
git rebase master foodle &&
149+
git checkout - &&
150+
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
151+
'
152+
119153
test_done

0 commit comments

Comments
 (0)