Subject: [BUG] builtin/checkout.c:1098: should be able to skip past 'refs/heads/'

From: Todd Zullinger <[email-masked]>
Date: Thu, 20 Jan 2022 11:51:37 -0500

Hi,

A bug was filed in the Fedora/Red Hat bugzilla today for the
git 2.35.0 rc (rc1, but it's the same in rc2).  Petr (Cc'd),
ran the following

    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__

The second git checkout call runs into the BUG() call added
in 9081a421a6 (checkout: fix "branch info" memory leaks,
2021-11-16):

    BUG: builtin/checkout.c:1098: should be able to skip
    past 'refs/heads/' in 'refs/remotes/origin/master'!
    Aborted (core dumped)

This worked in 2.34.1, so it's new to 2.35.0.  Should this
work or does the manual copy to setup a branch fall into a
new category of "don't do that"?

(It's novel to get a bug report from rc testing of a distro
build -- that doesn't happen often.)

-- 
Todd