On Thu, Jan 13, 2022 at 07:24:19PM +0100, Han-Wen Nienhuys wrote: > On Fri, Jan 7, 2022 at 11:17 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > > this is a resend of version 1 of this patch series to hopefully entice > > > some reviews. The only change is that v2 is rebased onto the current > > > main branch at commit e83ba647f7 (The seventh batch, 2022-01-05). The > > > following was from the orignial cover letter: > > > > I'll add Ævar, who has been making a lot of changes to the refs > > subsystem, and Han-Wen, whose work to add a new ref backend may need > > to interact with this change, as possible stake-holders to the CC list. > > Thanks for the consideration, Jun. As the hook is called from refs.c, > it should not make a difference for reftable. > > I looked over the patches. I didn't look at the bottom change to > packed/loose refs as I'm not an expert. > > The individual transaction updates already support their own flags, so > this change generates some confusion. Consider: > > int refs_delete_ref(struct ref_store *refs, const char *msg, > const char *refname, > const struct object_id *old_oid, > unsigned int flags) > > how would one delete a ref skipping the transaction hook? It will be > easy for someone to pass the SKIP_TRANSACTION_HOOK to > refs_delete_ref(), with surprising results. > > It might make sense to not introduce a new flag namespace, but use > update->flags instead. You'd have to add your new flag after > REF_SKIP_REFNAME_VERIFICATION. > Bonus is that you can unittest the new flag using the existing > ref-store helper without extra work. (check that a transaction with & > without the flag works as expected.) > > other than that, looks OK to me. Thanks for your feedback! In fact the first version I had locally did exactly that. But I found the end version result harder to reason about, most importantly because it's not a 100% clear to the reader whether all callsites which delete refs in the packed-backend via the files-backend are adapted or whether any of the callsites was missing. By having the flag in a central place it's immediately clear that the hook won't be run at all, which is exactly what we want here. Patrick
Attachment:
signature.asc
Description: PGP signature