diff options
| author | Rubén Justo <rjusto@gmail.com> | 2023-02-25 15:22:13 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-02-25 13:05:23 -0800 |
| commit | 279f42fa27b4ffd0b3ac7c9378043eeb413f0f5a (patch) | |
| tree | c546240fe0b3db0810c4b831b98b2b7b03ad2adf | |
| parent | branch: fix die_if_checked_out() when ignore_current_worktree (diff) | |
| download | git-279f42fa27b4ffd0b3ac7c9378043eeb413f0f5a.tar.gz git-279f42fa27b4ffd0b3ac7c9378043eeb413f0f5a.zip | |
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>
| -rwxr-xr-x | t/t3400-rebase.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index d5a8ee39fc..3ce918fdb8 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -388,6 +388,20 @@ test_expect_success 'switch to branch checked out here' ' git rebase main main ' +test_expect_success 'switch to branch checked out elsewhere fails' ' + test_when_finished " + git worktree remove wt1 && + git worktree remove wt2 && + git branch -d shared + " && + git worktree add wt1 -b shared && + git worktree add wt2 -f shared && + # we test in both worktrees to ensure that works + # as expected with "first" and "next" worktrees + test_must_fail git -C wt1 rebase shared shared && + test_must_fail git -C wt2 rebase shared shared +' + test_expect_success 'switch to branch not checked out' ' git checkout main && git branch other && |
