git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: pre-receive hook output invalid characters

From
Mmnaoumov@gmail.com <mnaoumov@gmail.com>
Date
Nov 1, 2012, 00:54 UTC
Message-ID
<b7f0b4cb-cf31-4abb-8682-5d43acaafbbf@googlegroups.com>
In-Reply-To
<CABPQNSb0pWAwwrZ5LvOY2agdEa+MXPMvg+kFa1vODhXf6efAZw@mail.gmail.com>
Your suggestion seems to be logical for me :)
On Thursday, November 1, 2012 3:32:26 AM UTC+11, Erik Faye-Lund wrote:
Show 65 quoted lines
>
> 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
Previous: Erik Faye-Lund
Message 3 of 3 in “Re: pre-receive hook output invalid characters”
  1. Erik Faye-LundOct 31, 2012
  2. pre-receive hook output invalid charactersErik Faye-Lund, Oct 31, 2012
  3. mnaoumov@gmail.comNov 1, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.