On Tue, Aug 2, 2022 at 8:18 PM Michael Heemskerk <mheemskerk@xxxxxxxxxxxxx> wrote: > > On Fri, Jul 29, 2022 at 12:20 PM Jiang Xin <worldhello.net@xxxxxxxxx> wrote: > > > > From: Jiang Xin <zhiyou.jx@xxxxxxxxxxxxxxx> > > > > If there are references to be deleted in a transaction, we should remove > > each reference from both loose references and the "packed-refs" file. > > The "reference-transaction" hook will run twice, once for the primary > > ref-store (loose references), and another for the second ref-store (i.e. > > packed ref-store). > > > > To avoid duplicate running of the "reference-trancaction" hook, we pass > > a special "hook-flags" parameter to initialize the second ref-store. > > The "REF_TRANSACTION_RUN_PREPARED_HOOK" bit is preserved for the > > transaction of the second ref-store because we may still want to call > > command "reference-trancaction prepared" for some pre-checks, such as > > terminate unwanted transaction for the "packed-refs" file. > > Can you elaborate on the rationale for continuing to invoke the "prepared" > reference-transaction hook for the "packed-refs" file? Did you have a specific > type of check in mind? Use "reference-transaction prepared" hook command, we can implement write lock for repositories. We can create a lock file (e.g. "site.lock") inside a repository or in a parent directory to disable write operations for one repository, a group of repositories or all repositories. The magic is in the "reference-transaction prepared" hook command. As a transaction may be triggered twice, one for packed-refs, and one for loose-refs, we should make sure the "reference-transaction prepared" command must run for both transactions on different ref-stores. BTW, I'm on vacation for the next few days and I will pick up this topic next week. -- Jiang Xin