refactor "dumb" terminal determination

Move the code to detect "dumb" terminals into a single location. This
avoids duplicating the terminal detection code yet again in a subsequent
commit.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Lars Schneider
2017-11-29 15:37:51 +01:00
committed by Junio C Hamano
parent 5a1f5c3060
commit a64f213d3f
4 changed files with 11 additions and 7 deletions

View File

@@ -20,13 +20,12 @@
int recv_sideband(const char *me, int in_stream, int out)
{
const char *term, *suffix;
const char *suffix;
char buf[LARGE_PACKET_MAX + 1];
struct strbuf outbuf = STRBUF_INIT;
int retval = 0;
term = getenv("TERM");
if (isatty(2) && term && strcmp(term, "dumb"))
if (isatty(2) && !is_terminal_dumb())
suffix = ANSI_SUFFIX;
else
suffix = DUMB_SUFFIX;