am/apply: warn if we end up reading patches from terminal

In an interactive session, "git am" without arguments, or even worse, "git am --whitespace file", waits silently for the user to feed the patches from the standard input (presumably by typing or copy-pasting). Give a feedback message to the user when this happens, as it is unlikely that the user meant to do so. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Mar 3, 2022 at 13:58 UTC 7b20af6a069f1be1ac0354451e0edd9825b22534
1 file changed +3
builtin/mailsplit.c
+3
@@ -223,6 +223,9 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
223 FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
224 int file_done = 0;
225
226 + if (isatty(fileno(f)))
227 + warning(_("reading patches from stdin/tty..."));
228 +
229 if (!f) {
230 error_errno("cannot open mbox %s", file);
231 goto out;