Skip to content

Commit 38de156

Browse files
mnaoumovgitster
authored andcommitted
sideband.c: do not use ANSI control sequence on non-terminal
Diagnostic messages received on the sideband #2 from the server side are sent to the standard error with ANSI terminal control sequence "\033[K" that erases to the end of line appended at the end of each line. However, some programs (e.g. GitExtensions for Windows) read and interpret and/or show the message without understanding the terminal control sequences, resulting them to be shown to their end users. To help these programs, squelch the control sequence when the standard error stream is not being sent to a tty. NOTE: I considered to cover the case that a pager has already been started. But decided that is probably not worth worrying about here, though, as we shouldn't be using a pager for commands that do network communications (and if we do, omitting the magic line-clearing signal is probably a sane thing to do). Thanks-to: Erik Faye-Lund <[email protected]> Thanks-to: Jeff King <[email protected]> Signed-off-by: Michael Naumov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a28f16 commit 38de156

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sideband.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int recv_sideband(const char *me, int in_stream, int out)
3030

3131
memcpy(buf, PREFIX, pf);
3232
term = getenv("TERM");
33-
if (term && strcmp(term, "dumb"))
33+
if (isatty(2) && term && strcmp(term, "dumb"))
3434
suffix = ANSI_SUFFIX;
3535
else
3636
suffix = DUMB_SUFFIX;

0 commit comments

Comments
 (0)