Description of problem: Checking out a manually created ref for the second time results in a core dump. Version-Release number of selected component (if applicable): git-2.35.0-0.1.rc1.fc36.x86_64 Steps to Reproduce: git clone https://github.com/psss/fmf /tmp/fmf cd /tmp/fmf cp .git/refs/remotes/origin/HEAD .git/refs/heads/__DEFAULT__ git checkout -f __DEFAULT__ git checkout -f __DEFAULT__ Actual results: Switched to branch '__DEFAULT__' BUG: builtin/checkout.c:1098: should be able to skip past 'refs/heads/' in 'refs/remotes/origin/master'! Aborted (core dumped) Expected results: Checkout works fine second time as well. Additional info: Works fine with git-2.34.1-1.fc35.x86_64. Related fmf issue: https://github.com/psss/fmf/issues/149
Thanks for the report Petr! This looks to have originated in upstream 9081a421a6 (checkout: fix "branch info" memory leaks, 2021-11-16). I sent a message upstream (with you on Cc:): https://lore.kernel.org/git/YemTGQZ97vAPUPY0@pobox.com/
Thanks for looking into this so quickly! According to the upstream discussion I see we're doing unexpected things by copying the remote ref to refs/heads. Would you recommend a better way to easily detect the default origin branch from a script within a repository where arbitrary branch is currently checked out? The use case is roughly this: git clone ... git checkout -b custom-branch ... git checkout -f <default-branch> git reset --hard origin/<default-branch> Thanks for any hint!
FEDORA-2022-a63d9a0b84 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-a63d9a0b84
FEDORA-2022-a63d9a0b84 has been pushed to the Fedora 36 stable repository. If problem still persists, please make note of it in this bug report.