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 <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Jun 16, 2013 at 14:15 UTC 89f2fea49a246e9ac4fa94cb43a7e992a8a4a144
1 file changed +34
t/t2012-checkout-last.sh
+34
@@ -116,4 +116,38 @@ test_expect_success 'master...' '
116 test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"
117 '
118
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 +
153 test_done