rebase: refuse to switch to a branch already checked out elsewhere (test)
In b5cabb4a9 (rebase: refuse to switch to branch already checked out elsewhere, 2020-02-23) we add a condition to prevent a rebase operation involving a switch to a branch that is already checked out in another worktree. A bug has recently been fixed that caused this to not work as expected. Let's add a test to notice if this changes in the future. Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Rubén Justo committed
Feb 25, 2023 at 15:22 UTC
279f42fa27b4ffd0b3ac7c9378043eeb413f0f5a
1 file changed
+14
t/t3400-rebase.sh
+14
@@ -388,6 +388,20 @@ test_expect_success 'switch to branch checked out here' '
388
git rebase main main
389
'
390
391
+test_expect_success 'switch to branch checked out elsewhere fails' '
392
+ test_when_finished "
393
+ git worktree remove wt1 &&
394
+ git worktree remove wt2 &&
395
+ git branch -d shared
396
+ " &&
397
+ git worktree add wt1 -b shared &&
398
+ git worktree add wt2 -f shared &&
399
+ # we test in both worktrees to ensure that works
400
+ # as expected with "first" and "next" worktrees
401
+ test_must_fail git -C wt1 rebase shared shared &&
402
+ test_must_fail git -C wt2 rebase shared shared
403
+'
404
+
405
test_expect_success 'switch to branch not checked out' '
406
git checkout main &&
407
git branch other &&