Re: [PATCH v2 02/10] hook: provide stdin via callback
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Oct 21, 2025, 14:44 UTC
- Message-ID
- <87y0p4pb4z.fsf@collabora.com>
- In-Reply-To
- <aPc5GhzFSdrMvOZK@pks.im>
On Tue, 21 Oct 2025, Patrick Steinhardt <ps@pks.im> wrote:
Show 24 quoted lines
> On Fri, Oct 17, 2025 at 05:15:36PM +0300, Adrian Ratiu wrote: >> diff --git a/hook.h b/hook.h index 11863fa734..ebe5dc450e >> 100644 --- a/hook.h +++ b/hook.h @@ -37,6 +38,28 @@ struct >> run_hooks_opt >> * Path to file which should be piped to stdin for each >> hook. */ const char *path_to_stdin; >> + + /** + * Callback to ask for more content to pipe to >> each hook stdin. + * + * If a hook needs to consume >> large quantities of data (e.g. a + * list of all refs >> received in a client push), feeding data via + * >> in-memory strings or slurping to/from files via path_to_stdin + >> * is inefficient, so this callback allows for piecemeal writes. >> + * + * Add initalization context to >> hook.feed_pipe_ctx. + * + * The caller owns >> hook.feed_pipe_ctx and has to release any + * resources after >> hooks finish execution. + */ + feed_pipe_fn feed_pipe; + >> void *feed_pipe_ctx; + + /** + * Use this to keep >> internal state for your feed_pipe_fn callback. + * Only >> useful when using run_hooks_opt.feed_pipe, otherwise ignore it. >> + */ + void *feed_pipe_cb_data; > > Are these fields used as any of the callback arguments? If so, > let's document which of the fields they correspond to, as it's > otherwise hard to follow.
I understand your point and will document this better.
They are not the callback args, they are passed as part of the struct run_hooks_opt accessible via the void *pp_cb arg like this:
struct hook_cb_data *hook_cb = pp_cb; struct receive_hook_feed_state *feed_state = hook_cb->options->feed_pipe_cb_data;