Subject: Re: [PATCH v1 1/8] compat/terminal: let prompt accept input from pipe

From: Junio C Hamano <[email-masked]>
Date: Fri, 07 May 2021 08:37:49 +0900

Firmin Martin <[email-masked]> writes:

> Currently, git_prompt ignores input coming from anywhere other than
> terminal (pipe, redirection etc.) meaning that standard prompt
> auto-answering methods would have no effect:
>
>         echo 'Y' | git ...
>         yes 'Y' | git ...
>         git ... <input.txt
>
> It also prevents git subcommands using git_prompt to be tested using
> such methods.

For testing, wouldn't lib-terminal.sh be usable for your purpose?
If not, what is the reason why it is insufficient?  Can we fix that
instead?

Allowing prompter to read from pipe has a big downside in the
production code: you cannot pipe data into our command, and let it
ask interactive questions from the end user by opening /dev/tty.

> This patch fixes this issue by considering standard input when !isatty(0).
> It also rearranges the control flow to close input and output file handlers.

So this "fix" is probably very unwelcome, especially if done
unconditionally.

Thanks.