git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* `git rebase (--no-fork-point) --onto=<newbase> [<upstream> [<branch>]]` leaves HEAD detached and *HEAD not moved when <branch> is exactly `HEAD`
@ 2024-09-01 11:02 Han Jiang
  2024-09-01 15:26 ` Phillip Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Han Jiang @ 2024-09-01 11:02 UTC (permalink / raw)
  To: git

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_";
mkdir --parents -- './server' './client';
git -C './server' init --bare './repo.git'
echo '1' >'./file'; git --git-dir='./server/repo.git' --work-tree='.'
add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit
-m "$((++number))"
echo '2' >'./file'; git --git-dir='./server/repo.git' --work-tree='.'
add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit
-m "$((++number))"
git -C './server/repo.git' log --graph --all --patch

git -C './client' clone '../server/repo.git' './repo'
branch_default_path="$(git -C './client/repo' symbolic-ref HEAD)"
branch_default_name="${branch_default_path#'refs/heads/'}"
echo '3' >'./client/repo/file'; git -C './client/repo' add './file';
git -C './client/repo' commit -m "$((++number))"
git -C './client/repo' log --graph --all --patch

git -C './server/repo.git' reset --soft HEAD~1
echo '4' >'./file'; git --git-dir='./server/repo.git' --work-tree='.'
add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit
-m "$((++number))"
git -C './server/repo.git' log --graph --all --patch

git -C './client/repo' fetch --all
git -C './client/repo' log --graph --all --patch
git -C './client/repo' -c 'core.editor=cat' rebase
--onto=HEAD@{upstream} --interactive "$(git -C './client/repo'
merge-base --fork-point HEAD@{upstream} HEAD)" HEAD
git -C './client/repo' log --graph --all --patch
echo '5' >'./client/repo/file'; git -C './client/repo' add './file';
git -C './client/repo' -c 'core.editor=:' rebase --continue
git -C './client/repo' log --graph --all --patch
git -C './client/repo' checkout -B "$branch_default_name"
git -C './client/repo' log --graph --all --patch

What did you expect to happen? (Expected behavior)

HEAD points to GIT_DEFAULT_BRANCH and GIT_DEFAULT_BRANCH points to tip
of origin's GIT_DEFAULT_BRANCH when rebase completes.

What happened instead? (Actual behavior)

HEAD is detached and *HEAD is not moved when rebase completes, so `git
checkout -B` is needed.

What's different between what you expected and what actually happened?

Anything else you want to add:

Replacing `HEAD` with branch name (`"$(git -C './client/repo' branch
--show-current)"`) works around the problem.
cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir "$_"; cd "$_";
mkdir --parents -- './server' './client';
git -C './server' init --bare './repo.git'
echo '1' >'./file'; git --git-dir='./server/repo.git' --work-tree='.'
add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit
-m "$((++number))"
echo '2' >'./file'; git --git-dir='./server/repo.git' --work-tree='.'
add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit
-m "$((++number))"
git -C './server/repo.git' log --graph --all --patch

git -C './client' clone '../server/repo.git' './repo'
echo '3' >'./client/repo/file'; git -C './client/repo' add './file';
git -C './client/repo' commit -m "$((++number))"
git -C './client/repo' log --graph --all --patch

git -C './server/repo.git' reset --soft HEAD~1
echo '4' >'./file'; git --git-dir='./server/repo.git' --work-tree='.'
add './file'; git --git-dir='./server/repo.git' --work-tree='.' commit
-m "$((++number))"
git -C './server/repo.git' log --graph --all --patch

git -C './client/repo' fetch --all
git -C './client/repo' log --graph --all --patch
git -C './client/repo' -c 'core.editor=cat' rebase
--onto=HEAD@{upstream} --interactive "$(git -C './client/repo'
merge-base --fork-point HEAD@{upstream} HEAD)" "$(git -C
'./client/repo' branch --show-current)"
git -C './client/repo' log --graph --all --patch
echo '5' >'./client/repo/file'; git -C './client/repo' add './file';
git -C './client/repo' -c 'core.editor=:' rebase --continue
git -C './client/repo' log --graph --all --patch

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.46.0.windows.1
cpu: x86_64
built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.9.0
OpenSSL: OpenSSL 3.2.2 4 Jun 2024
zlib: 1.3.1
uname: Windows 10.0 22631
compiler info: gnuc: 14.1
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe


[Enabled Hooks]
not run from a git repository - no hooks to show

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-03 15:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-01 11:02 `git rebase (--no-fork-point) --onto=<newbase> [<upstream> [<branch>]]` leaves HEAD detached and *HEAD not moved when <branch> is exactly `HEAD` Han Jiang
2024-09-01 15:26 ` Phillip Wood
2024-09-01 15:42   ` Junio C Hamano
2024-09-01 22:05     ` Han Jiang
2024-09-02  9:04     ` Phillip Wood
2024-09-03 15:38       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).