* Re: pre-receive hook output invalid characters [not found] ` <CABPQNSYj1-aaQieztkLxZjOhBQMqBJy+9POcmMcjGO4-a=EM9Q@mail.gmail.com> @ 2012-10-31 16:27 ` Erik Faye-Lund 2012-10-31 16:31 ` Erik Faye-Lund 0 siblings, 1 reply; 3+ messages in thread From: Erik Faye-Lund @ 2012-10-31 16:27 UTC (permalink / raw) To: mnaoumov; +Cc: msysgit, GIT Mailing-list [-- Attachment #1: Type: text/plain, Size: 2592 bytes --] On Wed, Oct 31, 2012 at 4:45 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote: > On Wed, Oct 31, 2012 at 4:24 PM, <mnaoumov@gmail.com> wrote: > >> If you add *pre-receive* hook in your git repository with the following >> content >> >> #!/bin/sh >> >> echo Message >> exit 1 >> >> And then try to push you will get the following >> >> [image: Git Extensions push]<https://a248.e.akamai.net/camo.github.com/04b160d6fd381c09c7b0a9f30400e981a086fd46/687474703a2f2f692e696d6775722e636f6d2f4431714b722e706e67> >> >> The bug is about these strange 3 last characters. >> >> Recently I raised a bug for GitExtensions but it seems to be msysgit >> issue as I could reproduce it from PowerShell as well >> >> https://github.com/gitextensions/gitextensions/issues/1313 >> >> > What you're seeing is most likely a CR (a carriage return character). > Windows has CRLF new-lines, and Unix uses only LF. > > My guess is that echo produces CRLF, and this gets carried through and > incorrecly displayed. > OK, I can reproduce it in Git Bash now, and by doing "git push 2>&1 | od -c" I can see that I'm getting "Message\033[K\n". This looks a little bit puzzling, but the sequence matches ANSI_SUFFIX in sideband.c. So it seems this is intentional. This dates back to ebe8fa73. I wonder, shouldn't we check isatty also before assuming ANSI-sequences? ---8<--- diff --git a/sideband.c b/sideband.c index d5ffa1c..bd3e5a8 100644 --- a/sideband.c +++ b/sideband.c @@ -29,7 +29,7 @@ int recv_sideband(const char *me, int in_stream, int out) memcpy(buf, PREFIX, pf); term = getenv("TERM"); - if (term && strcmp(term, "dumb")) + if (isatty(out) && term && strcmp(term, "dumb")) suffix = ANSI_SUFFIX; else suffix = DUMB_SUFFIX; ---8<--- Thoughts? Unfortunately, I cannot reproduce it; all my attempts on using a local > pre-receive hook seems to cause the following error: > > "error: cannot spawn hooks/pre-receive: No such file or directory" > > I have no clue why. > OK, that just me being stupid. -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en [-- Attachment #2: Type: text/html, Size: 6532 bytes --] ^ permalink raw reply related [flat|nested] 3+ messages in thread
* pre-receive hook output invalid characters 2012-10-31 16:27 ` pre-receive hook output invalid characters Erik Faye-Lund @ 2012-10-31 16:31 ` Erik Faye-Lund 2012-11-01 0:54 ` mnaoumov 0 siblings, 1 reply; 3+ messages in thread From: Erik Faye-Lund @ 2012-10-31 16:31 UTC (permalink / raw) To: GIT Mailing-list; +Cc: Michael Naumov, msysgit Sorry for resending, but the previous version got dropped from the main git mailing list due to a HTML-subpart. Converted to plain-text. On Wed, Oct 31, 2012 at 4:45 PM, Erik Faye-Lund <kusmabite@gmail.com> wrote: > > On Wed, Oct 31, 2012 at 4:24 PM, <mnaoumov@gmail.com> wrote: >> >> If you add pre-receive hook in your git repository with the following >> content >> >> #!/bin/sh >> >> echo Message >> exit 1 >> >> And then try to push you will get the following >> >> The bug is about these strange 3 last characters. >> >> Recently I raised a bug for GitExtensions but it seems to be msysgit >> issue as I could reproduce it from PowerShell as well >> >> https://github.com/gitextensions/gitextensions/issues/1313 > > What you're seeing is most likely a CR (a carriage return character). > Windows has CRLF new-lines, and Unix uses only LF. > > My guess is that echo produces CRLF, and this gets carried through and > incorrecly displayed. OK, I can reproduce it in Git Bash now, and by doing "git push 2>&1 | od -c" I can see that I'm getting "Message\033[K\n". This looks a little bit puzzling, but the sequence matches ANSI_SUFFIX in sideband.c. So it seems this is intentional. This dates back to ebe8fa73. I wonder, shouldn't we check isatty also before assuming ANSI-sequences? ---8<--- diff --git a/sideband.c b/sideband.c index d5ffa1c..bd3e5a8 100644 --- a/sideband.c +++ b/sideband.c @@ -29,7 +29,7 @@ int recv_sideband(const char *me, int in_stream, int out) memcpy(buf, PREFIX, pf); term = getenv("TERM"); - if (term && strcmp(term, "dumb")) + if (isatty(out) && term && strcmp(term, "dumb")) suffix = ANSI_SUFFIX; else suffix = DUMB_SUFFIX; ---8<--- Thoughts? -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: pre-receive hook output invalid characters 2012-10-31 16:31 ` Erik Faye-Lund @ 2012-11-01 0:54 ` mnaoumov 0 siblings, 0 replies; 3+ messages in thread From: mnaoumov @ 2012-11-01 0:54 UTC (permalink / raw) To: msysgit; +Cc: GIT Mailing-list, Michael Naumov, kusmabite [-- Attachment #1: Type: text/plain, Size: 2607 bytes --] Your suggestion seems to be logical for me :) On Thursday, November 1, 2012 3:32:26 AM UTC+11, Erik Faye-Lund wrote: > > Sorry for resending, but the previous version got dropped from the > main git mailing list due to a HTML-subpart. Converted to plain-text. > > On Wed, Oct 31, 2012 at 4:45 PM, Erik Faye-Lund <kusm...@gmail.com<javascript:>> > wrote: > > > > On Wed, Oct 31, 2012 at 4:24 PM, <mnao...@gmail.com <javascript:>> > wrote: > >> > >> If you add pre-receive hook in your git repository with the following > >> content > >> > >> #!/bin/sh > >> > >> echo Message > >> exit 1 > >> > >> And then try to push you will get the following > >> > >> The bug is about these strange 3 last characters. > >> > >> Recently I raised a bug for GitExtensions but it seems to be msysgit > >> issue as I could reproduce it from PowerShell as well > >> > >> https://github.com/gitextensions/gitextensions/issues/1313 > > > > > > > What you're seeing is most likely a CR (a carriage return character). > > Windows has CRLF new-lines, and Unix uses only LF. > > > > My guess is that echo produces CRLF, and this gets carried through and > > incorrecly displayed. > > > OK, I can reproduce it in Git Bash now, and by doing "git push 2>&1 | od > -c" > I can see that I'm getting "Message\033[K\n". > > This looks a little bit puzzling, but the sequence matches ANSI_SUFFIX in > sideband.c. So it seems this is intentional. This dates back to ebe8fa73. > > I wonder, shouldn't we check isatty also before assuming ANSI-sequences? > > ---8<--- > diff --git a/sideband.c b/sideband.c > index d5ffa1c..bd3e5a8 100644 > --- a/sideband.c > +++ b/sideband.c > @@ -29,7 +29,7 @@ int recv_sideband(const char *me, int in_stream, int > out) > > memcpy(buf, PREFIX, pf); > term = getenv("TERM"); > - if (term && strcmp(term, "dumb")) > + if (isatty(out) && term && strcmp(term, "dumb")) > suffix = ANSI_SUFFIX; > else > suffix = DUMB_SUFFIX; > ---8<--- > > Thoughts? > -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en [-- Attachment #2: Type: text/html, Size: 3538 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-01 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1b3d3eb1-ed6c-4d03-8fdb-bf2ba2163647@googlegroups.com>
[not found] ` <CABPQNSYj1-aaQieztkLxZjOhBQMqBJy+9POcmMcjGO4-a=EM9Q@mail.gmail.com>
2012-10-31 16:27 ` pre-receive hook output invalid characters Erik Faye-Lund
2012-10-31 16:31 ` Erik Faye-Lund
2012-11-01 0:54 ` mnaoumov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox