Subject: Re: [PATCH v2 01/10] run-command: add stdin callback for parallelization

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 21 Oct 2025 09:40:56 +0200

On Fri, Oct 17, 2025 at 05:15:35PM +0300, Adrian Ratiu wrote:
> diff --git a/run-command.c b/run-command.c
> index ed9575bd6a..5bc6db5bb1 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1652,6 +1652,44 @@ static int pp_start_one(struct parallel_processes *pp,
>  	return 0;
>  }
>  
> +static void pp_buffer_stdin(struct parallel_processes *pp,
> +			    const struct run_process_parallel_opts *opts)
> +{
> +	/* Buffer stdin for each pipe. */
> +	for (ssize_t i = 0; i < opts->processes; i++) {

This should use `size_t` to match the type of `opts->processes`.

> diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
> index 3719f23cc2..dfdb03b3ab 100644
> --- a/t/helper/test-run-command.c
> +++ b/t/helper/test-run-command.c
> @@ -54,15 +61,48 @@ static int no_job(struct child_process *cp UNUSED,
>  static int task_finished(int result UNUSED,
>  			 struct strbuf *err,
>  			 void *pp_cb UNUSED,
> -			 void *pp_task_cb UNUSED)
> +			 void *pp_task_cb)
>  {
>  	if (err)
>  		strbuf_addstr(err, "asking for a quick stop\n");
>  	else
>  		fprintf(stderr, "asking for a quick stop\n");
> +	if (pp_task_cb)
> +		FREE_AND_NULL(pp_task_cb);

Tiny nit: the conditional here is not needed.

>  	return 1;
>  }
>  
> +static int task_finished_quiet(int result UNUSED,
> +			       struct strbuf *err UNUSED,
> +			       void *pp_cb UNUSED,
> +			       void *pp_task_cb)
> +{
> +	if (pp_task_cb)
> +		FREE_AND_NULL(pp_task_cb);

Same over here.

Patrick