Bug 2042920 - Checkout of a custom ref fails with a core dump
Summary: Checkout of a custom ref fails with a core dump
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: git
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Todd Zullinger
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-20 11:13 UTC by Petr Šplíchal
Modified: 2022-01-25 02:01 UTC (History)
8 users (show)

Fixed In Version: git-2.35.0-1.fc36
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-25 02:01:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Petr Šplíchal 2022-01-20 11:13:02 UTC
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

Comment 1 Todd Zullinger 2022-01-20 16:56:09 UTC
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/

Comment 2 Petr Šplíchal 2022-01-21 10:38:39 UTC
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!

Comment 3 Fedora Update System 2022-01-25 01:59:14 UTC
FEDORA-2022-a63d9a0b84 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-a63d9a0b84

Comment 4 Fedora Update System 2022-01-25 02:01:20 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.