Subject: Re: [PATCH v2 02/10] hook: provide stdin via callback

From: Adrian Ratiu <[email-masked]>
Date: Tue, 21 Oct 2025 17:44:44 +0300

On Tue, 21 Oct 2025, Patrick Steinhardt <[email-masked]> wrote:
> 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;