Re: [PATCH 02/10] hook: provide stdin via callback
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Oct 13, 2025, 14:47 UTC
- Message-ID
- <87o6qag8p6.fsf@gentoo.mail-host-address-is-not-set>
- In-Reply-To
- <CAJoAoZm6uNtEoo_tdbqjGMSj4OnQuFesxt_iyOTgNHA1LX3iwQ@mail.gmail.com>
On Fri, 10 Oct 2025, Emily Shaffer <nasamuffin@google.com> wrote:
Show 39 quoted lines
> On Thu, Sep 25, 2025 at 5:54 AM Adrian Ratiu
> <adrian.ratiu@collabora.com> wrote:
>> diff --git a/hook.h b/hook.h index 11863fa734..8fdbc8c673
>> 100644 --- a/hook.h +++ b/hook.h @@ -1,6 +1,7 @@
>> #ifndef HOOK_H #define HOOK_H #include "strvec.h"
>> +#include "run-command.h"
>>
>> struct repository;
>>
>> @@ -37,6 +38,24 @@ 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 +
>> * will not be efficient, so this callback allows for piecemeal
>> reading and writing. + * + * Add initalization
>> context to hook.feed_pipe_ctx. + */ +
>> feed_pipe_fn feed_pipe; + void *feed_pipe_ctx; + +
>> /** + * Use this to keep internal state for your
>> feed_pipe_fn callback. + * Only useful if you are using
>> run_hooks_opt.feed_pipe. Otherwise, ignore it. + */ +
>> void *feed_pipe_cb_data;
>> };
>>
>> #define RUN_HOOKS_OPT_INIT { \
>> @@ -44,6 +63,9 @@ struct run_hooks_opt
>> .args = STRVEC_INIT, \
>> }
>>
>> +/** + * Callback data provided to feed_pipe_fn. + */
>
> It looks like this comment was maybe a note to yourself? (Or a
> note to myself, eons ago?) But hook_cb_data is used in all the
> parallel hook callbacks, not just feed_pipe_fn, so I don't think
> this is accurate. Nice find! I added the comment while initially understanding the code and yes, hook_cb_data is more generic than just its use in feed_pipe_fn.
Will drop it in v2. Thanks!