Re: [BUG] reference-transaction reports zero OIDs for branch and tag deletion
- From
Maciej Ciemborowicz <maciej.ciemborowicz@gmail.com>
- Date
- Sep 19, 2026, 15:42 UTC
- Message-ID
- <CACQ=SRHthWOLVXmY6wgknOPgpQ+oB1vV-Q0AL=mK9mXb2Xy9Nw@mail.gmail.com>
- In-Reply-To
- <CALnO6CBUr3=Cj57ikytiPxU-1hZkYu1Z3fRPydhFLqJHprbDew@mail.gmail.com>
Commit `6754159767` introduced `reference-transaction` in Git 2.28. In Git 2.28-2.30, `git branch -D` and `git tag -d` used `delete_ref()` with the known old OID. Commit `8198907795`, before Git 2.31, replaced single-ref deletion with `delete_refs()`. The new function preserved only the ref names and called:
```c ref_transaction_delete(transaction, refname, NULL, NULL, ...) ```
Without the old OID, the `REF_HAVE_OLD` flag is not set, so the hook receives:
```text 000000... 000000... refs/heads/topic ```
The change was intended to speed up deletion of 24,000 tags from roughly 30 minutes to 5 seconds. The loss of information exposed to the hook appears to have been a side effect. So I assume this is a bug introduced by that optimization, and it should be fixed in a way that preserves the performance improvement. That seems feasible.
Cheers, Maciej Ciemborowicz
On Sat, Sep 19, 2026 at 4:59 PM D. Ben Knoble <ben.knoble@gmail.com> wrote:
Show 20 quoted lines
> > On Sat, Sep 19, 2026 at 9:34 AM Maciej Ciemborowicz > <maciej.ciemborowicz@gmail.com> wrote: > > > > Since Git 2.31, the reference-transaction hook receives all-zero old and > > new object IDs when a branch or tag is deleted with a high-level command. > > [snip] > > > Was this loss of information intentional? If not, could the previous > > object ID be restored for these deletion paths? If it is intentional, > > the documentation may need to clarify that high-level deletion commands > > can provide a zero-to-zero record. > > Since you seem to have identified a "good" and "bad" version with a > reproduction script, I suspect "git bisect" is a good way to answer > your questions about intent. > > -- > D. Ben Knoble