xuyongli73 / tortoisegit

Automatically exported from code.google.com/p/tortoisegit
1 stars 0 forks source link

GIT_SSH can't be a script #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I need to work around not having GIT in my $PATH on the server.  (I put it in 
/var/tmp/pcordes/bin).  

What steps will reproduce the problem?
1. In TortoiseGit's settings, set Network->SSH client to a .bat or .sh file
useful contents of a bat file for debugging would include 
echo %* > ssh.log
(Note that it doesn't get that far, though)
2. push an existing repo to a remote repo using an ssh:// URL

What is the expected output?
git runs my bat file, which runs TortoisePlink %1 /var/tmp/pcordes/bin/%2
to add an absolute path on the command sent

 What do you see instead?
(in the TortoiseGit push dialog):
git.exe push    "ssh://pcordes@xserve:/.../pcordes/try1.git" master

fatal: unable to fork

What version of the product are you using?
git version 1.6.2.1217.gd7bc3
TortoiseGit 0.4.2

 On what operating system?
WinXP, unfortunately.

extra info:
I assume TortoiseGit sets the GIT_SSH environment variable.

I can set the GUI setup SSH client to 
C:\Program Files\TortoiseGit\bin\TortoisePlink.exe  and it pops up the password 
dialog, then I get this error:
  bash: line 1: git-receive-pack: command not found
  fatal: The remote end hung up unexpectedly
(as expected, hence this workaround)  If I don't specify an ssh client, then it 
hangs 
waiting for my password on stdin.  (I don't have a home directory on the server 
(don't ask), so I can't set up ssh keys.)  You should probably run openssh with 
-o 
"Batchmode yes" since there is no tty.

 From the msys bash shell (started from the "Git bash" start menu entry set up by 
msys git), I can get a little further:
GIT_SSH='/c/temp/pjc/plink.bat'  git push ...
runs the bat file.

 It doesn't work with spaces in the pathname, though.
GIT_SSH='/c/Program Files/TortoiseGit/plink.bat'  git push ...
'c:/Program' is not recognized as an internal or external command,
operable program or batch file.

same result with GIT_SSH='c:\Program Files\TortoiseGit\plink.bat'
(note that this is _different_ from setting the same path in the settings GUI.
TortoiseGit probably needs to run git the same way msys bash does, or it will 
get 
"unable to fork" errors.  http://code.google.com/p/msysgit/issues/detail?id=49
Note that you also get "unable to fork" when the path pointed to by $GIT_SSH 
doesn't 
exist.)

In all cases, my plink.bat contains:
@echo off
echo %* > c:\temp\plink.log
"C:\Program Files\TortoiseGit\bin\TortoisePlink.exe"  "%1" 
"/var/tmp/pcordes/bin/%2"

 When I get it working, I'm going to put -pw ... on the cmdline too.

Original issue reported on code.google.com by pcor...@gmail.com on 11 Mar 2009 at 4:29

GoogleCodeExporter commented 9 years ago
I think I have it working by pointing the GUI at C:\temp\pjc\plink.bat
However it passes the path to git, it doesn't work with spaces in filenames.  
So the 
"unable to fork" is from trying to run something that doesn't exist.

Original comment by pcor...@gmail.com on 11 Mar 2009 at 4:34

GoogleCodeExporter commented 9 years ago
Does it work with git command line?

Original comment by lzn...@gmail.com on 12 Mar 2009 at 2:42

GoogleCodeExporter commented 9 years ago
> Does it work with git command line?

not exactly, but TortoiseGit fails in a different way than some of my cmdline 
attempts.

 Also, both cmdline and tortoisegit work fine when the path to the batch file doesn't 
contain any spaces.

 As I said (somewhere in the middle of my last message):
On the msys bash command line:
GIT_SSH='c:\Program Files\TortoiseGit\plink.bat' git push ...    outputs:
'c:/Program' is not recognized as an internal or external command,
operable program or batch file.

 But TortoiseGit just says:
fatal: unable to fork

 So, no, batch files with spaces in their names don't work on the command line 
either.

 This is probably actually msys git's fault, since it doesn't seem to be possible to 
quote it a path to a batch file properly.  It's fine with an exe with spaces in 
the 
path, but maybe .bat is different if it's trying to run cmd.exe on it.  If you 
quote 
the path to 

 I hate \ as a path separator _and_ as a quote character, but I think in bourne shell 
quoting, \ isn't special inside single quotes.

further testing:
 GIT_SSH="/c/temp/p c/git-plink.bat" git push ...
'c:/temp/p' is not recognized as an internal or external command,
operable program or batch file.

 And if you use "\ " to quote the space inside the msys forward-slash path, you get 
"unable to fork".
c:/temp/p  

 I think TortoiseGit is putting a non-working path into GIT_SSH, maybe by quoting 
spaces or something.  Probably msys git checks if the path is valid, and bails 
if 
not, and only after that does pass it to a shell which does quote-removal and 
word-
splitting.  So if you quote the path to survive a trip through the shell, it 
won't be 
a valid path when msys checks early in its fork/exec.  (I actually don't know 
how 
msys emulates fork...)  But if you don't quote the path, msys will word-split 
it in 
the process of exec()ing it.

BTW, I had to give up on git over ssh, because the remote machine always prints 
"cannot chdir to home directory", because I don't have one.  This noise 
injection 
breaks git clone/pull, even though push seems to be ok.  I got it working over 
SMB, 
but I had to use file:// URLs to invoke the git-aware transport.  msys git 
crashes 
with plain local file URLs.  (I'll report that to them.)

Original comment by pcor...@gmail.com on 12 Mar 2009 at 1:14

GoogleCodeExporter commented 9 years ago
reported to msys git as:
http://code.google.com/p/msysgit/issues/detail?id=203

Original comment by pcor...@gmail.com on 12 Mar 2009 at 1:26

GoogleCodeExporter commented 9 years ago
Does this issue still exist at 0.7.2.0?

Original comment by lzn...@gmail.com on 29 Jun 2009 at 8:15

GoogleCodeExporter commented 9 years ago
Issue 103 has been merged into this issue.

Original comment by lzn...@gmail.com on 30 Jun 2009 at 1:16

GoogleCodeExporter commented 9 years ago
msysgit problem

Original comment by lzn...@gmail.com on 4 Apr 2010 at 1:17