{"thread":{"id":"36771","subject":"[PATCH] sideband.c: Get rid of ANSI sequences for non-terminal shell","startedAt":"2014-05-28T03:12:15Z","lastAt":"2014-05-29T17:45:16Z","messageCount":2,"participants":["Naumov, Michael (North Sydney)","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"242834","messageId":"81E85F13A4BE084BAF4B1AA24173EDA012924D8B@JWPKEXMBX03.corp.checkfree.com","threadId":"36771","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-05-28T03:12:15Z","receivedAt":"2014-05-28T03:12:15Z","isPatch":true,"sender":{"key":"michael.naumov@fiserv.com","avatar":"https://gravatar.com/avatar/9f0ba13d842c458d2e476a63746adc1325c81f3c25f19d241938acfd21549f50?d=mp&s=160"},"body":"Some git tools such as GitExtensions for Windows use environment variable TERM=msys which causes the weird ANSI sequence shown for the messages returned from server-side hooks\nWe add those ANSI sequences to help format sideband data on the user's terminal. However, GitExtensions is not using a terminal, and the ANSI sequences just confuses it. We can recognize this use by checking isatty().\nSee https://github.com/gitextensions/gitextensions/issues/1313 for more details\n\nNOTE: 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).\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 character\nP.S 2. Sorry, my tab character has been eaten again!\n\nRegards,\nMichael\n"},{"id":"242968","messageId":"20140529174516.GA10865@sigill.intra.peff.net","threadId":"36771","inReplyTo":"81E85F13A4BE084BAF4B1AA24173EDA012924D8B@JWPKEXMBX03.corp.checkfree.com","subject":"Re: [PATCH] sideband.c: Get rid of ANSI sequences for non-terminal shell","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-05-29T17:45:16Z","receivedAt":"2014-05-29T17:45:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 28, 2014 at 03:12:15AM +0000, Naumov, Michael (North Sydney) wrote:\n\n> Some git tools such as GitExtensions for Windows use environment\n> variable TERM=msys which causes the weird ANSI sequence shown for the\n> messages returned from server-side hooks\n> We add those ANSI sequences to help format sideband data on the user's\n> terminal. However, GitExtensions is not using a terminal, and the ANSI\n> sequences just confuses it. We can recognize this use by checking\n> isatty().\n> See https://github.com/gitextensions/gitextensions/issues/1313 for\n> more details\n\nPlease wrap your commit messages (and emails) at something reasonable to\nfit on an 80-char terminal with indentation (I usually use 60, but\nanything <= 72 is probably fine).\n\nOther than that, I think the patch looks fine.\n\n> P.S. I gave up trying to send this letter from gmail, it eats my tab character\n> P.S 2. Sorry, my tab character has been eaten again!\n\nThis version looks OK to me (and applies via git-am).\n\n-Peff\n"}]}