Mercurial > kallithea
changeset 5999:58809814b51d
hooks: set Windows stderr output mode to binary
This prevents Python (or the Windows console) from replacing \n with \r\n. The
extra \r made exception output show up with empty lines.
Assuming we only get text and never binary data on stderr, an alternative
solution could be to strip trailing whitespace ...
author | domruf <dominikruf@gmail.com> |
---|---|
date | Tue, 14 Jun 2016 21:23:51 +0200 |
parents | 037efd94e955 |
children | 023d9202481e |
files | kallithea/config/post_receive_tmpl.py kallithea/config/pre_receive_tmpl.py |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/config/post_receive_tmpl.py Mon Jun 13 21:39:47 2016 +0200 +++ b/kallithea/config/post_receive_tmpl.py Tue Jun 14 21:23:51 2016 +0200 @@ -1,6 +1,15 @@ import os import sys +# set output mode on windows to binary for stderr +# this prevents python (or the windows console) from replacing \n with \r\n +# git doesn't display remote output lines that contain \r +# and therefore without this modification git would displayes empty lines +# instead of the exception output +if sys.platform == "win32": + import msvcrt + msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) + KALLITHEA_HOOK_VER = '_TMPL_' os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER from kallithea.lib.hooks import handle_git_post_receive as _handler
--- a/kallithea/config/pre_receive_tmpl.py Mon Jun 13 21:39:47 2016 +0200 +++ b/kallithea/config/pre_receive_tmpl.py Tue Jun 14 21:23:51 2016 +0200 @@ -1,6 +1,15 @@ import os import sys +# set output mode on windows to binary for stderr +# this prevents python (or the windows console) from replacing \n with \r\n +# git doesn't display remote output lines that contain \r +# and therefore without this modification git would displayes empty lines +# instead of the exception output +if sys.platform == "win32": + import msvcrt + msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) + KALLITHEA_HOOK_VER = '_TMPL_' os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER from kallithea.lib.hooks import handle_git_pre_receive as _handler