]> Kevux Git Server - rit/commit
hook: add internal state alloc/free callbacks
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Wed, 18 Feb 2026 22:23:45 +0000 (00:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Feb 2026 21:23:40 +0000 (13:23 -0800)
commitee2fbfd6b28fba20bc936ad1c2cb2617ba251025
treeb956dd564d34592160e4ee9a507d2b15138b9fd0
parent468b5f75c3e277d84e2d739e642fbad27ccdb666
hook: add internal state alloc/free callbacks

Some hooks use opaque structs to keep internal state between callbacks.

Because hooks ran sequentially (jobs == 1) with one command per hook,
these internal states could be allocated on the stack for each hook run.

Next commits add the ability to run multiple commands for each hook, so
the states cannot be shared or stored on the stack anymore, especially
since down the line we will also enable parallel execution (jobs > 1).

Add alloc/free helpers for each hook, doing a "deep" alloc/init & free
of their internal opaque struct.

The alloc callback takes a context pointer, to initialize the struct at
at the time of resource acquisition.

These callbacks must always be provided together: no alloc without free
and no free without alloc, otherwise a BUG() is triggered.

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c
hook.c
hook.h
refs.c
transport.c