From: John Cai via GitGitGadget Date: Thu, 17 Mar 2022 19:53:46 GMT Subject: [PATCH v4 1/3] rebase: test showing bug in rebase with non-branch Message-ID: In-Reply-To: From: John Cai Currently when rebase is used with a non branch, and is up to date with base: git rebase base It will update the ref that HEAD is pointing at to , 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 in detached HEAD mode. Signed-off-by: John Cai Reported-by: Michael McClimon --- 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