From: Adrian Ratiu Date: Thu, 27 Nov 2025 14:24:42 GMT Subject: Re: [PATCH v3 04/10] transport: convert pre-push to hook API Message-ID: <87qztjimdx.fsf@collabora.com> In-Reply-To: On Mon, 24 Nov 2025, Junio C Hamano wrote: > Adrian Ratiu writes: > >> From: Emily Shaffer >> >> Move the pre-push hook from custom run-command invocations to >> the new hook API which doesn't require a custom child_process >> structure and signal toggling. >> >> Signed-off-by: Emily Shaffer >> Signed-off-by: Ævar Arnfjörð Bjarmason >> Signed-off-by: Adrian Ratiu --- >> transport.c | 95 >> ++++++++++++++++++++++++++++------------------------- 1 file >> changed, 51 insertions(+), 44 deletions(-) > > So, this completes what 01/10 hinted at when it created a > generalized interface modelled after how pre-push hook was run. > We used to spawn the pre-push hook and fed its standard input by > calling write_in_full(). Now that is largely encapsulated in > run_hooks_opt(), but the application specific processing > (namely, what we write to the pre-push hook, i.e. the list of > ref update status) is given in pre_push_hook_feed_stdin() > callback defined here and given to the run_hooks_opt() call. > > In other words, the mechanisms are very cleanly separated > between generic machinery and the client specific processing. > Nice. > > How and where does the pipe we are writing into > (i.e. hook_stdin_fd) gets closed when we are done with the > child? That happens in run-command.c:pp_buffer_stdin() which calls the feed pipe callback then closes the fd when feeding is finished: /** * Feed the pipe: * ret < 0 means error * ret == 0 means there is more data to be fed * ret > 0 means feeding finished */ ret = opts->feed_pipe(proc->in, opts->data, pp->children[i].data); ...