Subject: Re: [PATCH 3/5] hook API: support passing stdin to hooks, convert am's 'post-rewrite'

From: Junio C Hamano <[email-masked]>
Date: Mon, 23 Jan 2023 15:13:45 -0800

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> @@ -53,8 +53,14 @@ static int pick_next_hook(struct child_process *cp,
>  	if (!hook_path)
>  		return 0;
>  
> -	cp->no_stdin = 1;
>  	strvec_pushv(&cp->env, hook_cb->options->env.v);
> +	/* reopen the file for stdin; run_command closes it. */
> +	if (hook_cb->options->path_to_stdin) {
> +		cp->no_stdin = 0;
> +		cp->in = xopen(hook_cb->options->path_to_stdin, O_RDONLY);
> +	} else {
> +		cp->no_stdin = 1;
> +	}

By the way, using the path_to_stdin as the customization machinery
for the API users, and keeping it to the API implementation to
actually open the file and stuff .in member with it, is a good way
to make sure that multiple processes do not compete for the same
standard input stream.  IOW, what I was worried about in my review
of [2/5] is addressed by this mechanism.

Thanks.