Subject: Re: [PATCH] add a reflog_exists and delete_reflog abstraction

From: Junio C Hamano <[email-masked]>
Date: Tue, 06 May 2014 12:15:10 -0700

Ronnie Sahlberg <[email-masked]> writes:

> It currently has a hard assumption that the loose ref file must exist at this
> stage or else it would end up deleting the reflog which is true today, as far
> as I can tell, but would break if git would change such that we could have
> a branch checked out without having a loose ref file for that branch.

Hmmmm.  Do you mean this sequence will break?

        : gitster x; git init lo
        Initialized empty Git repository in /var/tmp/x/lo/.git/
        : gitster x; cd lo
        : gitster lo/master; git commit --allow-empty -m initial
        [master (root-commit) db2b430] initial
        : gitster lo/master; git branch next

Now we have two branches, master and next, and we are on master.

        : gitster lo/master; git pack-refs --all
        : gitster lo/master; ls .git/refs/heads
        ./  ../
        : gitster lo/master; cat .git/packed-refs
        # pack-refs with: peeled fully-peeled 
        db2b43072749258d1e3c119c9570349d77c26b3a refs/heads/master
        db2b43072749258d1e3c119c9570349d77c26b3a refs/heads/next

And loose refs are fully packed.

        : gitster lo/master; git checkout next
        Switched to branch 'next'
        : gitster lo/next; ls .git/refs/heads
        ./  ../