From: Jiang Xin <zhiyou.jx@xxxxxxxxxxxxxxx> Before Patrick introduced the reference-transaction hook in git 2.28, We had implemented some internal transaction hooks "pre-txn" and "post-txn" for our internal git infrastructure. The "pre-txn" hook is used to check our site-wide lockfile to disable write services for the repository. The "post-txn" hook is used to update the timestamp and checksum of the repository. Recently I wanted to migrate our internal implementation to use ref-txn hooks, but I ran into the same issues reported by Michael and Bryan: * https://lore.kernel.org/git/CAGyf7-GYYA2DOnAVYW--=QEc2WjSHzUhp2OQyuyOr3EOtFDm6g@xxxxxxxxxxxxxx/ * https://lore.kernel.org/git/pull.1228.git.1651676435634.gitgitgadget@xxxxxxxxx/ This patch series try to fix the issues I encountered. Patch 1/9 adds more testcases in t1416: * Some commands failed because the expected "<old-oid>" was * "<zero-oid>". Such as: "git update-ref -d <ref>". * Some commands failed because the "reference-transaction committed" command was repeated multiple times for the same changes. Such as: "git update-ref -d <ref>" and "git tag -d <tag>". * Some commands should not trigger the "reference-transaction" hook because no real changes have occurred to the repository. Such as: "git pack-refs --all" and "git gc". * Some commands did not execute the "reference-transaction" hook at * all. Such as: "git branch -c <src> <dest>", "git branch -m <old> <new>" Patch 2/9 propagates real old-oid found in lockfile to the update entry for txn, so we can get proper old-oid in "prepared" and "committed" stage for ref-txn hook. Patch 3/9 adds a new flag in transaction, and we can turn off running the entire hook for git-pack-refs in patch 4/9. We can also turn off the "committed" and "aborted" stages of the ref-txn hook for "packed-ref-store", but we can still run "prepared" stage of the hook. See patch 5/9. Patch 6/9 and 7/9 create an extended function "ref_transaction_update_extended()" to be used in patch 8/9 to reimplement branch copy and rename. Patch 9/9 reimplents "files_delete_refs()" to fix failed testcases for "git branch -d" and "git tag -d". -- Jiang Xin (9): t1416: more testcases for reference-transaction hook refs: update missing old-oid in transaction from lockfile refs: add new field in transaction for running transaction hook refs: do not run transaction hook for git-pack-refs refs: avoid duplicate running of the reference-transaction hook refs: add reflog_info to hold more fields for reflog entry refs: get error message via refs_update_ref_extended() refs: reimplement files_copy_or_rename_ref() to run hook refs: reimplement refs_delete_refs() and run hook once refs.c | 99 ++- refs.h | 23 + refs/debug.c | 2 +- refs/files-backend.c | 158 ++--- refs/packed-backend.c | 51 +- refs/refs-internal.h | 25 +- t/t1416-ref-transaction-hooks.sh | 1072 +++++++++++++++++++++++++++++- t/t5510-fetch.sh | 17 + 8 files changed, 1264 insertions(+), 183 deletions(-) -- 2.36.1.25.gc87d5ad63a.dirty