On Mon, Mar 14, 2022 at 11:52 AM Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote: > > I think you might find it interesting to have pre-receive hooks > e.g. reject pushes if you're deleting a topic whose commits aren't > entirely <your author> i.e. just something like: > > git push -o ireallymeanit=1 --delete topic > > I.e. it's an easy to implement extra safety check that people can always > opt-out of, print a scary message and most people will think twice :) That is indeed very interesting, thanks! I need to think about exactly when this is the right thing to do, but it's a tool in the box that I was not aware of! > > My question is specifically about the, in my opinion, very surprising > > behavior of deleting reflogs along with deleted branches - I mainly > > provided the example use-case for context. > > Yes it's quite a mess, e.g. if you follow the rabit hole at the > recent[1]. > > One fundimental problem (discussed in various places around the reftable > backend) is that we carry N meanings for an empty reflog: > > A. "This is an active branch, but we have expired the entries". > > B. "I manually created this, knowing that the various core.* configs > around reflog will say "oh, a reflog exists, let's log to it" (in > some cases). > > C. Another is: This is "stale" log, i.e. no branch exists, but the log > is there. > > Which is one reason[2] we'd delete them on branch deletion, because > otherwise we'd start logging again when a branch is re-created, which > possibly isn't what we wanted. > > 1. https://lore.kernel.org/git/de5e2b0e290791d0a4f58a893d8571b5fc8c4f1a.1646952843.git.avarab@xxxxxxxxx > 2. I'm not saying this was intended, and haven't looked into this case, > just that's it it's an emergent effect of how these files are treated > now. Very interesting, thx. Fwiw I would argue that resuming full logging when a new branch appears with the same name (within the period of time where the reflog is not empty yet) is a very reasonable thing to end up doing, but I guess Han-Wen's note about potential path conflicts on branches *after* a deletion make this a hard thing to change, even if "accidental logging resuming" were accepted as a sensible outcome here.