I've been trying all day to make git work inside emacs shells (version 24) on Windows 7 x86. (*) The culprit is actually ssh, which won't work. For instance, typing:
ssh -T git@github.com
will hang forever, whatever the type of shell used inside emacs (the emacs shell (aka eshell) or msys bash). Outside of emacs, it works just fine (in bash or cmd.exe).
Note the -T
parameter, which says "do not allocate a pseudo-tty" (emacs cannot allocate a pseudo-tty, at least not on Windows). So that's not the issue.
I've tried using ssh.exe from either MSYS (not msys-git) or "Git for Windows". Beware! "Git for Windows" is not the same thing as "Github for Windows". "Git for Windows" is an installer for the binaries and support utilities obtained by building git under msys-git (a development environment existing solely for this purpose). For this reason, it "Git for Windows" often mistakingly referred to as msys-git.
Enter "Github for Windows". Using their version of git/ssh, I'm able to use git and ssh under emacs shells. As far as I can tell, the program simply uses "Git for Windows" under the wraps. However, it's a modified version. For instance, there is an etc/ssh/ssh_config
file that was added.
I've already determined that some of the configurations in etc/ssh/ssh_config
are primordial for ssh to work in emacs. However, that alone doesn't explain why it works, as using this config file with "Git for Windows" doesn't do the trick.
So what I'd like to know is what other changes the Github team has made to "Git for Windows" in order for it to work in emacs.
I'm not even sure that "working in emacs" was an intended goal. That's why the answer to this question is important: if a future version of "Github for Windows" breaks emacs-compatibility, I won't be able to use git inside the emacs shells anymore.
(*) Yes, I know all about vc-git, magit, tramp, etc. I'm not interested.
Basically ssh is hanging when it prompts for a password. Due to some internal detail of Windows, input is treated differently when it comes from a pipe (Emacs), vs when it is typed in a console window (bash or cmd.exe). If ssh.exe and git.exe are not flushing their buffers at the right time, input can get left in limbo between them when it is piped in from Emacs. This only occurs when Emacs is running a subprocess that runs another subprocess of its own, which requests input.
The only workaround I know of without digging into the source code of git and ssh, is to use public-key authentication with ssh-agent, and pre-authorize your key before trying to use git from Emacs. This will eliminate the need for ssh to prompt for a password. I don't know whether this is an option for github though.