{"thread":{"id":"36820","subject":"[PATCH] sideband.c: Get rid of ANSI sequences for non-terminal shell","startedAt":"2014-06-02T23:40:51Z","lastAt":"2014-06-02T23:40:51Z","messageCount":1,"participants":["Naumov, Michael (North Sydney)"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"243172","messageId":"81E85F13A4BE084BAF4B1AA24173EDA0144E47EC@JWPKEXMBX03.corp.checkfree.com","threadId":"36820","inReplyTo":null,"subject":"[PATCH] sideband.c: Get rid of ANSI sequences for non-terminal shell","fromName":"Naumov, Michael (North Sydney)","fromEmail":"michael.naumov@fiserv.com","sentAt":"2014-06-02T23:40:51Z","receivedAt":"2014-06-02T23:40:51Z","isPatch":true,"sender":{"key":"michael.naumov@fiserv.com","avatar":"https://gravatar.com/avatar/9f0ba13d842c458d2e476a63746adc1325c81f3c25f19d241938acfd21549f50?d=mp&s=160"},"body":"From: Michael Naumov <mnaoumov@gmail.com>\n\nDiagnostic messages received on the sideband #2 from the server side\nare sent to the standard error with ANSI terminal control sequence\n\"\\033[K\" that erases to the end of line appended at the end of each\nline.\n\nHowever, some programs (e.g. GitExtensions for Windows) read and\ninterpret and/or show the message without understanding the terminal\ncontrol sequences, resulting them to be shown to their end users.\nTo help these programs, squelch the control sequence when the\nstandard error stream is not being sent to a tty.\n\nNOTE: I considered to cover the case that a pager has already been \nstarted. But decided that is probably not worth worrying about here, \nthough, as we shouldn't be using a pager for commands that do network \ncommunications (and if we do, omitting the magic line-clearing signal \nis probably a sane thing to do).\n\nSigned-off-by: Michael Naumov <mnaoumov@gmail.com>\nThanks-to: Erik Faye-Lund <kusmabite@gmail.com>\nThanks-to: Jeff King <peff@peff.net>\n---\n sideband.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sideband.c b/sideband.c\nindex d1125f5..7f9dc22 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -30,7 +30,7 @@ int recv_sideband(const char *me, int in_stream, int out)\n \n \tmemcpy(buf, PREFIX, pf);\n \tterm = getenv(\"TERM\");\n-\tif (term && strcmp(term, \"dumb\"))\n+\tif (isatty(2) && term && strcmp(term, \"dumb\"))\n \t\tsuffix = ANSI_SUFFIX;\n \telse\n \t\tsuffix = DUMB_SUFFIX;\n-- \n1.8.3.msysgit.0\n\nP.S. I gave up trying to send this letter from gmail, it eats my tab\ncharacter\nP.S 2. Sorry, my tab character has been eaten again!\nP.S 3. Wrapped the letter lines to fit on the terminal\nP.S 4. GitExtensions tried to use TERM=dumb but this caused process leakage for diff tools. See https://github.com/gitextensions/gitextensions/issues/1092\n\nRegards,\nMichael\n"}]}