git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Keep reflogs for deleted (remote tracking) branches?

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 14, 2022, 10:44 UTC
Message-ID
<220314.86y21cerhe.gmgdl@evledraar.gmail.com>
In-Reply-To
<CAPMMpoiDTprbf_9J3gY6WQwUVWfOTms6LVyJDYQUOcUp-42doA@mail.gmail.com>
On Mon, Mar 14 2022, Tao Klerks wrote:
Show 10 quoted lines
> On Tue, Mar 8, 2022 at 2:05 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>> More generally I have not really run into this as a practical
>> problem.
>
> That's fair, nor have I - but I *have* come reasonably close: one
> person accidentally deletes a branch that someone else had prepared
> *without even realizing*, and the initial author is not available, and
> I only find out about it a few hours later. Dangling commit hunt, here
> we come. (the original author became available and re-pushed before it
> came to that)

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 :)

Show 16 quoted lines
>> Another way to solve a similar problem is to have
>> pre-receive/post-receive hooks log attempted/successful pushes, which
>> along with an appropriate "gc" policy will allow you to manually look up
>> these older branches (or even to fetch them, if you publish the log and
>> set uploadpack.allowAnySHA1InWant=true).
>
> Yep, that's closer to my expected plan, thanks - my intent is to back
> up, on force-push and/or deletion, into a specific refspace with a
> cleanup policy, using a server hook. So after something is "deleted"
> (or force-pushed away), it can be easily recovered for a period of eg
> 3 months in that refspace, eg
> "refs/force-push-backups/YYYY-MM-DD-<BRANCHNAME>-<HASHPREFIX>".
>
> 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@gmail.com
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.
Previous: Tao KlerksNext: Tao Klerks
Message 5 of 8 in “Keep reflogs for deleted (remote tracking) branches?”
  1. Tao KlerksMar 8, 2022
  2. Han-Wen NienhuysMar 8, 2022
  3. Ævar Arnfjörð BjarmasonMar 8, 2022
  4. Tao KlerksMar 14, 2022
  5. Ævar Arnfjörð BjarmasonMar 14, 2022
  6. Tao KlerksMar 14, 2022
  7. Jeff HostetlerMar 8, 2022
  8. Tao KlerksMar 14, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.