]> git.ipfire.org Git - thirdparty/git.git/commitdiff
am/apply: warn if we end up reading patches from terminal
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 Mar 2022 21:58:39 +0000 (13:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Mar 2022 22:00:32 +0000 (14:00 -0800)
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>
builtin/mailsplit.c

index 7baef30569fce8e6b4a7353067bb4aba00561557..30952353a370a3343f614ee5a14a3f5ca9560444 100644 (file)
@@ -223,6 +223,9 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
        FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
        int file_done = 0;
 
+       if (isatty(fileno(f)))
+               warning(_("reading patches from stdin/tty..."));
+
        if (!f) {
                error_errno("cannot open mbox %s", file);
                goto out;