{"thread":{"id":"32025","subject":"Fwd: [PATCH] Remove terminal symbols from non-terminal console","startedAt":"2012-11-05T23:17:21Z","lastAt":"2012-11-08T16:51:06Z","messageCount":2,"participants":["Michael Naumov","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"202574","messageId":"CABHRWd16k6B4Ybvc4k7z29_A9Q2wZVXA__Bov8Pst4cc2H0cmg@mail.gmail.com","threadId":"32025","inReplyTo":"CABHRWd1T=a8Mze20G9koiTr0L2Nrq0g3vGLC9mEZ7rA45vgfSA@mail.gmail.com","subject":"Fwd: [PATCH] Remove terminal symbols from non-terminal console","fromName":"Michael Naumov","fromEmail":"mnaoumov@gmail.com","sentAt":"2012-11-05T23:17:21Z","receivedAt":"2012-11-05T23:17:21Z","isPatch":true,"sender":{"key":"mnaoumov@gmail.com","avatar":null},"body":"As per discussion on msysgit user group:\nhttps://groups.google.com/forum/?fromgroups=#!topic/msysgit/U_a982_a3rc/discussion\nwe found the following patch is required to get rid of weird terminal\ncharacters for other tools such as GitExtensions for Windows\n\n---8<---\ndiff --git a/sideband.c b/sideband.c\nindex d5ffa1c..bd3e5a8 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -29,7 +29,7 @@ int recv_sideband(const char *me, int in_stream, int out)\n\n  memcpy(buf, PREFIX, pf);\n  term = getenv(\"TERM\");\n- if (term && strcmp(term, \"dumb\"))\n+ if (isatty(out) && term && strcmp(term, \"dumb\"))\n  suffix = ANSI_SUFFIX;\n  else\n  suffix = DUMB_SUFFIX;\n---8<---\n"},{"id":"202652","messageId":"20121108165106.GF15560@sigill.intra.peff.net","threadId":"32025","inReplyTo":"CABHRWd16k6B4Ybvc4k7z29_A9Q2wZVXA__Bov8Pst4cc2H0cmg@mail.gmail.com","subject":"Re: Fwd: [PATCH] Remove terminal symbols from non-terminal console","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-11-08T16:51:06Z","receivedAt":"2012-11-08T16:51:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 06, 2012 at 10:17:21AM +1100, Michael Naumov wrote:\n\n> As per discussion on msysgit user group:\n> https://groups.google.com/forum/?fromgroups=#!topic/msysgit/U_a982_a3rc/discussion\n> we found the following patch is required to get rid of weird terminal\n> characters for other tools such as GitExtensions for Windows\n> \n> ---8<---\n\nPlease follow SubmittingPatches (missing signoff, weird use of scissors\nmarker that cuts out your commit message, and your commit message should\nsummarize the discussion).\n\n> @@ -29,7 +29,7 @@ int recv_sideband(const char *me, int in_stream, int out)\n> \n>   memcpy(buf, PREFIX, pf);\n>   term = getenv(\"TERM\");\n> - if (term && strcmp(term, \"dumb\"))\n> + if (isatty(out) && term && strcmp(term, \"dumb\"))\n>   suffix = ANSI_SUFFIX;\n>   else\n>   suffix = DUMB_SUFFIX;\n\nIs that right? The \"out\" fd is where we send sideband 1, and it is\nalmost always not going to be a tty. The suffix should be sent with\nsideband 2, which goes to stderr. So I'd think you would want to check\nisatty(2).\n\nAlso, most isatty checks also need to cover the case that a pager has\nalready been started.  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 is\nprobably a sane thing to do).\n\nI think the overall goal is a step in the right direction, though.\n\n-Peff\n"}]}