From fb8bd549ab200327aca9dc93b5a6d2127a8b76d9 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 12 Aug 2009 17:39:44 +0200 Subject: [PATCH] Git installer: If GIT_SSH is set, also set SVN_SSH, so "git svn" will work Note that, in contrast to GIT_SSH, SVN_SSH needs to have its backslashes escaped *and* be surrounded by quotes. Additionally, reword some comments. This fixes msysGit issue 305. Signed-off-by: Johannes Schindelin --- share/WinGit/install.iss | 63 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss index 0fdbfa1c..5543a0c7 100644 --- a/share/WinGit/install.iss +++ b/share/WinGit/install.iss @@ -375,8 +375,8 @@ begin with LblOpenSSH do begin Parent:=PuTTYPage.Surface; Caption:= - 'This uses ssh.exe that comes with Git. The GIT_SSH environment' + #13 + - 'variable will not be modified.'; + 'This uses ssh.exe that comes with Git. The GIT_SSH and SVN_SSH' + #13 + + 'environment variables will not be modified.'; Left:=ScaleX(28); Top:=ScaleY(32); Width:=ScaleX(324); @@ -400,11 +400,11 @@ begin Parent:=PuTTYPage.Surface; Caption:= 'This uses (Tortoise)Plink.exe from the TortoiseSVN/CVS or PuTTY' + #13 + - 'applications which need to be provided by the user. The GIT_SSH' + #13 + - 'environment variable will be set to the executable specified below.'; + 'applications which need to be provided by the user. The GIT_SSH and' + #13 + + 'SVN_SSH environment variables will point to the below executable:'; Left:=ScaleX(28); Top:=ScaleY(100); - Width:=ScaleX(316); + Width:=ScaleX(340); Height:=ScaleY(39); end; EdtPlink:=TEdit.Create(PuTTYPage); @@ -673,7 +673,7 @@ begin FileName:=AppDir+'\setup.ini'; - // Delete GIT_SSH if a previous installation modified it. + // Delete GIT_SSH and SVN_SSH if a previous installation set them (this is required for the GS_OpenSSH case). EnvSSH:=GetEnvStrings('GIT_SSH',IsAdminLoggedOn); if (GetArrayLength(EnvSSH)=1) and (CompareStr(EnvSSH[0],GetIniString('Environment','GIT_SSH','',FileName))=0) then begin @@ -686,9 +686,23 @@ begin end; end; + EnvSSH:=GetEnvStrings('SVN_SSH',IsAdminLoggedOn); + if (GetArrayLength(EnvSSH)=1) and + (CompareStr(EnvSSH[0],GetIniString('Environment','SVN_SSH','',FileName))=0) then begin + if not SetEnvStrings('SVN_SSH',IsAdminLoggedOn,True,[]) then begin + Msg:='Line {#emit __LINE__}: Unable to reset SVN_SSH prior to install.'; + MsgBox(Msg,mbError,MB_OK); + Log(Msg); + // This is not a critical error, the user can probably fix it manually, + // so we continue. + end; + end; + if RdbSSH[GS_Plink].Checked then begin SetArrayLength(EnvSSH,1); EnvSSH[0]:=EdtPlink.Text; + + // Set GIT_SSH as specified by the user. if not SetEnvStrings('GIT_SSH',IsAdminLoggedOn,True,EnvSSH) then begin Msg:='Line {#emit __LINE__}: Unable to set the GIT_SSH environment variable.'; MsgBox(Msg,mbError,MB_OK); @@ -697,7 +711,7 @@ begin // so we continue. end; - // Mark that we have changed GIT_SSH. + // Mark that we have changed GIT_SSH by writing its value to a file. if not SetIniString('Environment','GIT_SSH',EnvSSH[0],FileName) then begin Msg:='Line {#emit __LINE__}: Unable to write to file "'+FileName+'".'; MsgBox(Msg,mbError,MB_OK); @@ -705,6 +719,27 @@ begin // This is not a critical error, though uninstall / reinstall will probably not run cleanly, // so we continue. end; + + // Set SVN_SSH as specified by the user, but with escaped backslashes and quotes. + StringChangeEx(EnvSSH[0],'\','\\',True); + EnvSSH[0]:=AddQuotes(EnvSSH[0]); + + if not SetEnvStrings('SVN_SSH',IsAdminLoggedOn,True,EnvSSH) then begin + Msg:='Line {#emit __LINE__}: Unable to set the SVN_SSH environment variable.'; + MsgBox(Msg,mbError,MB_OK); + Log(Msg); + // This is not a critical error, the user can probably fix it manually, + // so we continue. + end; + + // Mark that we have changed SVN_SSH by writing its value to a file. + if not SetIniString('Environment','SVN_SSH',EnvSSH[0],FileName) then begin + Msg:='Line {#emit __LINE__}: Unable to write to file "'+FileName+'".'; + MsgBox(Msg,mbError,MB_OK); + Log(Msg); + // This is not a critical error, though uninstall / reinstall will probably not run cleanly, + // so we continue. + end; end; // Get the current user's directories in PATH. @@ -899,7 +934,7 @@ begin AppDir:=ExpandConstant('{app}'); Command:=AppDir+'\setup.ini'; - // Reset the current user's GIT_SSH if we modified it. + // Delete the current user's GIT_SSH and SVN_SSH if we set it. EnvSSH:=GetEnvStrings('GIT_SSH',IsAdminLoggedOn); if (GetArrayLength(EnvSSH)=1) and (CompareStr(EnvSSH[0],GetIniString('Environment','GIT_SSH','',Command))=0) then begin @@ -912,6 +947,18 @@ begin end; end; + EnvSSH:=GetEnvStrings('SVN_SSH',IsAdminLoggedOn); + if (GetArrayLength(EnvSSH)=1) and + (CompareStr(EnvSSH[0],GetIniString('Environment','SVN_SSH','',Command))=0) then begin + if not SetEnvStrings('SVN_SSH',IsAdminLoggedOn,True,[]) then begin + Msg:='Line {#emit __LINE__}: Unable to revert any possible changes to SVN_SSH.'; + MsgBox(Msg,mbError,MB_OK); + Log(Msg); + // This is not a critical error, the user can probably fix it manually, + // so we continue. + end; + end; + // Get the current user's directories in PATH. EnvPath:=GetEnvStrings('PATH',IsAdminLoggedOn); -- 2.11.4.GIT