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

Re: [PATCH] git-remote-hg: set stdout to binary mode on win32

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 19, 2013, 11:23 UTC
Message-ID
<CAMP44s2h6O9_H=e9r_pSqdyU5O_NAFD94S8kZNC_eN_CJz-g7g@mail.gmail.com>
In-Reply-To
<CAFGOX=V0A=2kMpxtNvsjgEtMt=zsm_-zX_DJo0qkV9y1_C4Haw@mail.gmail.com>
On Mon, Jan 28, 2013 at 4:13 PM, Amit Bakshi <ambakshi@gmail.com> wrote:
Show 34 quoted lines
> git clone hangs on windows (msysgit/cygwin), and
> file.write would return errno 22 inside of mercurial's
> windows.winstdout wrapper class. This patch sets
> stdout's mode to binary, fixing both issues.
> ---
>  contrib/remote-helpers/git-remote-hg | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/contrib/remote-helpers/git-remote-hg
> b/contrib/remote-helpers/git-remote-hg
> index 328c2dc..95f4c1f 100755
> --- a/contrib/remote-helpers/git-remote-hg
> +++ b/contrib/remote-helpers/git-remote-hg
> @@ -62,6 +62,24 @@ def get_config(config):
>      output, _ = process.communicate()
>      return output
>
> +#
> +# On Windows (msysgit/cygwin) have to set stdout to binary
> +# mode (_O_BINARY is 32768). Otherwise clone hangs, and pushing
> +# to remote fails when doing a write to mercurial's wrapper
> +# windows.winstdout wrapper class.
> +#
> +def set_binmode(fd):
> +    try:
> +        if sys.platform == "win32":
> +            import msvcrt
> +            msvcrt.setmode(fd, os.O_BINARY)
> +        elif sys.platform  == 'cygwin':
> +            import ctypes
> +            msvcrt = ctypes.CDLL('msvcrt.dll')
> +            msvcrt._setmode(fd, 32768) # On Cygwin os.O_BINARY is different
> +    except OSError:
> +        pass

I tried many things, and it seems it's true that we need to set the binary mode in Windows, but it seemed to work fine cygwin. I saw in many places the workaround for 'win32', but I didn't find the one for 'cygwin'. Where did you find it? Did you test in cygwin? Is it needed there?

Cheers.
-- 
Felipe Contreras
Previous: Junio C Hamano
Message 3 of 3 in “Re: [PATCH] git-remote-hg: set stdout to binary mode on win32”
  1. Felipe ContrerasMay 19, 2013
  2. Junio C HamanoMay 19, 2013
  3. Felipe ContrerasMay 19, 2013

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.