Re: [PATCH 04/10] transport: convert pre-push hook to hook.h
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Sep 29, 2025, 11:33 UTC
- Message-ID
- <87zfadbiie.fsf@collabora.com>
- In-Reply-To
- <1f942894-9393-4b5c-8d7f-2d0aaad594f1@gmail.com>
On Fri, 26 Sep 2025, Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 28 quoted lines
> Hi Adrian
>
> On 25/09/2025 13:53, Adrian Ratiu wrote:
>>
>> -static int run_pre_push_hook(struct transport *transport,
>> - struct ref *remote_refs)
>> +static int pre_push_hook_feed_stdin(int hook_stdin_fd, void *pp_cb, void *pp_task_cb UNUSED)
>> {
>> - int ret = 0, x;
>> - struct ref *r;
>> - struct child_process proc = CHILD_PROCESS_INIT;
>> - struct strbuf buf;
>> - const char *hook_path = find_hook(the_repository, "pre-push");
>> -
>> - if (!hook_path)
>> - return 0;
>> + struct hook_cb_data *hook_cb = pp_cb;
>> + struct ref *r = hook_cb->options->feed_pipe_ctx;
>>
>> - strvec_push(&proc.args, hook_path);
>> - strvec_push(&proc.args, transport->remote->name);
>> - strvec_push(&proc.args, transport->url);
>> + if (r) {
>> + struct strbuf buf = STRBUF_INIT;
>
> If we passed the strbuf in as part of the context and called
> strbuf_reset() before using it each time we'd avoid allocating a new
> buffer for each ref just as the current code does.That is a good idea. Will do it in v2. Thanks!