[PATCH v4 1/3] rebase: test showing bug in rebase with non-branch
- From
John Cai via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Mar 17, 2022, 19:53 UTC
- Message-ID
- <cac51a949eed0fa593247a593aae2b100be6f4f2.1647546828.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1226.v4.git.git.1647546828.gitgitgadget@gmail.com>
From: John Cai <johncai86@gmail.com>
Currently when rebase is used with a non branch, and <oid> is up to date with base:
git rebase base <oid>
It will update the ref that HEAD is pointing at to <oid>, and leave HEAD unmodified.
This is a bug. The expected behavior is that the branch HEAD points at remains unmodified while HEAD is updated to point to <oid> in detached HEAD mode.
Signed-off-by: John Cai <johncai86@gmail.com> Reported-by: Michael McClimon <michael@mcclimon.org> --- t/t3400-rebase.sh | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 71b1735e1dd..5c4073f06d6 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -399,6 +399,15 @@ test_expect_success 'switch to branch not checked out' ' git rebase main other ' +test_expect_success 'switch to non-branch changes branch HEAD points to' ' + git checkout main && + old_main=$(git rev-parse HEAD) && + git rebase First Second^0 && + test_cmp_rev HEAD main && + test_cmp_rev main $(git rev-parse Second) && + git symbolic-ref HEAD +' + test_expect_success 'refuse to switch to branch checked out elsewhere' ' git checkout main && git worktree add wt &&
-- gitgitgadget