2 #define APP_VERSION
'%APPVERSION%'
3 #define APP_URL
'http://msysgit.googlecode.com/'
4 #define APP_BUILTINS
'etc\fileList-builtins.txt'
8 InternalCompressLevel
=max
9 OutputBaseFilename
={#emit APP_NAME+'-'+APP_VERSION}
13 ; Uncomment the line below to be able to compile the script from within the IDE.
14 ;SourceDir={#GetEnv('TEMP')}\WinGit
18 AppName
={#emit APP_NAME}
19 AppPublisherURL
={#emit APP_URL}
20 AppVersion
={#emit APP_VERSION}
21 AppVerName
={#emit APP_NAME+' '+APP_VERSION}
22 ChangesEnvironment
=yes
23 DefaultDirName
={pf}\
{#emit APP_NAME}
24 DefaultGroupName
={#emit APP_NAME}
26 InfoBeforeFile
=gpl
-2.0.rtf
27 PrivilegesRequired
=none
28 UninstallDisplayIcon
=etc\git
.ico
31 SetupIconFile
=etc\git
.ico
32 WizardImageBackColor
=clWhite
34 WizardImageFile
=git
.bmp
35 WizardSmallImageFile
=gitsmall
.bmp
38 ; Define a dummy type to avoid getting the default ones.
39 Name
: custom
; Description
: Custom installation
; Flags
: iscustom
42 Name
: icons
; Description
: Additional icons
; Types
: custom
43 Name
: icons\quicklaunch
; Description
: In the Quick Launch
; Types
: custom
44 Name
: icons\desktop
; Description
: On the Desktop
; Types
: custom
45 Name
: ext
; Description
: Windows Explorer integration
; Types
: custom
46 Name
: ext\shellhere
; Description
: """Git Bash Here"" context menu entry"; Types
: custom
47 Name
: ext\guihere
; Description
: """Git GUI Here"" context menu entry"; Types
: custom
48 Name
: assoc
; Description
: Associate
.git
* configuration
files with the default
text editor
; Types
: custom
49 Name
: consolefont
; Description
: Use a TrueType font
in the
console (required
for proper character encoding
); Types
: custom
52 Source
: *; DestDir
: {app}; Excludes
: \
*.bmp
, gpl
-2.0.rtf
, \
*.iss
, \tmp
.*, \bin\
*install
*; Flags
: recursesubdirs replacesameversion
53 Source
: ReleaseNotes
.rtf
; DestDir
: {app}; Flags
: isreadme replacesameversion
56 Name
: {group}\Git GUI
; Filename
: {app}\bin\wish
.exe
; Parameters
: """{app}\libexec\git-core\git-gui"""; WorkingDir
: %HOMEDRIVE
%%HOMEPATH
%; IconFilename
: {app}\etc\git
.ico
57 Name
: {group}\Git Bash
; Filename
: {syswow64}\cmd
.exe
; Parameters
: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir
: %HOMEDRIVE
%%HOMEPATH
%; IconFilename
: {app}\etc\git
.ico
58 Name
: {group}\Uninstall Git
; Filename
: {uninstallexe}
59 Name
: {userappdata}\Microsoft\Internet Explorer\Quick Launch\Git Bash
; Filename
: {syswow64}\cmd
.exe
; Parameters
: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir
: %HOMEDRIVE
%%HOMEPATH
%; IconFilename
: {app}\etc\git
.ico
; Components
: icons\quicklaunch
60 Name
: {code:GetShellFolder|desktop}\Git Bash
; Filename
: {syswow64}\cmd
.exe
; Parameters
: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir
: %HOMEDRIVE
%%HOMEPATH
%; IconFilename
: {app}\etc\git
.ico
; Components
: icons\desktop
62 ; Create a special shortcut that does not set a working directory. This is used by "Git Bash.vbs", which in turn is run by the "Git Bash Here" shell extension.
63 Name
: {app}\Git Bash
; Filename
: {syswow64}\cmd
.exe
; Parameters
: "/c """"{app}\bin\sh.exe"" --login -i"""; IconFilename
: {app}\etc\git
.ico
66 BeveledLabel
={#emit APP_URL}
67 SetupAppTitle
={#emit APP_NAME} Setup
68 SetupWindowTitle
={#emit APP_NAME} Setup
71 ; There is no "Console" key in HKLM.
72 Root
: HKCU
; Subkey
: Console
; ValueType
: string; ValueName
: FaceName
; ValueData
: Lucida Console
; Components
: consolefont
73 Root
: HKCU
; Subkey
: Console
; ValueType
: dword
; ValueName
: FontFamily
; ValueData
: $00000036; Components
: consolefont
74 Root
: HKCU
; Subkey
: Console
; ValueType
: dword
; ValueName
: FontSize
; ValueData
: $000e0000; Components
: consolefont
75 Root
: HKCU
; Subkey
: Console
; ValueType
: dword
; ValueName
: FontWeight
; ValueData
: $00000190; Components
: consolefont
77 Root
: HKCU
; Subkey
: Console\Git Bash
; ValueType
: string; ValueName
: FaceName
; ValueData
: Lucida Console
; Flags
: createvalueifdoesntexist
78 Root
: HKCU
; Subkey
: Console\Git Bash
; ValueType
: dword
; ValueName
: FontFamily
; ValueData
: $00000036; Flags
: createvalueifdoesntexist
79 Root
: HKCU
; Subkey
: Console\Git Bash
; ValueType
: dword
; ValueName
: FontSize
; ValueData
: $000e0000; Flags
: createvalueifdoesntexist
80 Root
: HKCU
; Subkey
: Console\Git Bash
; ValueType
: dword
; ValueName
: FontWeight
; ValueData
: $00000190; Flags
: createvalueifdoesntexist
82 ; File associations for configuration files that may be contained in a repository (so this does not include ".gitconfig").
83 Root
: HKLM
; Subkey
: Software\Classes\
.gitattributes
; ValueType
: string; ValueData
: txtfile
; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
84 Root
: HKLM
; Subkey
: Software\Classes\
.gitattributes
; ValueType
: string; ValueName
: Content
Type; ValueData
: text/plain
; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
85 Root
: HKLM
; Subkey
: Software\Classes\
.gitattributes
; ValueType
: string; ValueName
: PerceivedType
; ValueData
: text; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
86 Root
: HKCU
; Subkey
: Software\Classes\
.gitattributes
; ValueType
: string; ValueData
: txtfile
; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
87 Root
: HKCU
; Subkey
: Software\Classes\
.gitattributes
; ValueType
: string; ValueName
: Content
Type; ValueData
: text/plain
; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
88 Root
: HKCU
; Subkey
: Software\Classes\
.gitattributes
; ValueType
: string; ValueName
: PerceivedType
; ValueData
: text; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
90 Root
: HKLM
; Subkey
: Software\Classes\
.gitignore
; ValueType
: string; ValueData
: txtfile
; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
91 Root
: HKLM
; Subkey
: Software\Classes\
.gitignore
; ValueType
: string; ValueName
: Content
Type; ValueData
: text/plain
; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
92 Root
: HKLM
; Subkey
: Software\Classes\
.gitignore
; ValueType
: string; ValueName
: PerceivedType
; ValueData
: text; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
93 Root
: HKCU
; Subkey
: Software\Classes\
.gitignore
; ValueType
: string; ValueData
: txtfile
; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
94 Root
: HKCU
; Subkey
: Software\Classes\
.gitignore
; ValueType
: string; ValueName
: Content
Type; ValueData
: text/plain
; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
95 Root
: HKCU
; Subkey
: Software\Classes\
.gitignore
; ValueType
: string; ValueName
: PerceivedType
; ValueData
: text; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
97 Root
: HKLM
; Subkey
: Software\Classes\
.gitmodules
; ValueType
: string; ValueData
: txtfile
; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
98 Root
: HKLM
; Subkey
: Software\Classes\
.gitmodules
; ValueType
: string; ValueName
: Content
Type; ValueData
: text/plain
; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
99 Root
: HKLM
; Subkey
: Software\Classes\
.gitmodules
; ValueType
: string; ValueName
: PerceivedType
; ValueData
: text; Flags
: createvalueifdoesntexist; Check
: IsAdminLoggedOn
; Components
: assoc
100 Root
: HKCU
; Subkey
: Software\Classes\
.gitmodules
; ValueType
: string; ValueData
: txtfile
; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
101 Root
: HKCU
; Subkey
: Software\Classes\
.gitmodules
; ValueType
: string; ValueName
: Content
Type; ValueData
: text/plain
; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
102 Root
: HKCU
; Subkey
: Software\Classes\
.gitmodules
; ValueType
: string; ValueName
: PerceivedType
; ValueData
: text; Flags
: createvalueifdoesntexist; Check
: not IsAdminLoggedOn
; Components
: assoc
105 ; Delete the built-ins.
106 Type: files; Name
: {app}\bin\git
-*.exe
107 Type: files; Name
: {app}\libexec\git
-core\git
-*.exe
108 Type: files; Name
: {app}\libexec\git
-core\git
.exe
110 ; Delete a home directory inside the msysGit directory.
111 Type: dirifempty; Name
: {app}\home\
{username}
112 Type: dirifempty; Name
: {app}\home
115 #include
"helpers.inc.iss"
116 #include
"putty.inc.iss"
118 function CreateHardLink(lpFileName
,lpExistingFileName
:String;lpSecurityAttributes
:Integer):Boolean;
120 external 'CreateHardLinkW@Kernel32.dll stdcall delayload setuponly';
122 external 'CreateHardLinkA@Kernel32.dll stdcall delayload setuponly';
125 function CreateSymbolicLink(lpSymlinkFileName
,lpTargetFileName
:String;dwFlags
:DWORD
):Boolean;
127 external 'CreateSymbolicLinkW@Kernel32.dll stdcall delayload setuponly';
129 external 'CreateSymbolicLinkA@Kernel32.dll stdcall delayload setuponly';
142 // Git line ending conversion options
.
145 GC_CRLFCommitAsIs
= 3;
148 // Wizard page
and variables
for the Path options
.
149 PathPage
:TWizardPage
;
150 RdbPath
:array[GP_BashOnly
..GP_CmdTools
] of TRadioButton
;
152 // Wizard page
and variables
for the SSH options
.
153 PuTTYPage
:TWizardPage
;
154 RdbSSH
:array[GS_OpenSSH
..GS_Plink
] of TRadioButton
;
157 // Wizard page
and variables
for the line ending conversion options
.
158 CRLFPage
:TWizardPage
;
159 RdbCRLF
:array[GC_LFOnly
..GC_CRLFCommitAsIs
] of TRadioButton
;
161 procedure BrowseForPuTTYFolder(Sender
:TObject
);
165 Path
:=ExtractFilePath(EdtPlink
.Text);
166 BrowseForFolder('Please select the PuTTY folder:',Path
,False);
167 if FileExists(Path
+'\TortoisePlink.exe') then begin
168 EdtPlink
.Text:=Path
+'\TortoisePlink.exe';
169 RdbSSH
[GS_Plink
].Checked
:=True;
170 end else if FileExists(Path
+'\plink.exe') then begin
171 EdtPlink
.Text:=Path
+'\plink.exe';
172 RdbSSH
[GS_Plink
].Checked
:=True;
174 MsgBox('Please enter a valid path to "TortoisePlink.exe" or "plink.exe".',mbError
,MB_OK
);
182 procedure InitializeWizard
;
185 LblGitBash
,LblGitCmd
,LblGitCmdTools
,LblGitCmdToolsWarn
:TLabel
;
186 LblOpenSSH
,LblPlink
:TLabel
;
187 PuTTYSessions
:TArrayOfString
;
188 LblLFOnly
,LblCRLFAlways
,LblCRLFCommitAsIs
:TLabel
;
192 PrevPageID
:=wpSelectProgramGroup
;
195 * Create a custom page for modifying the environment.
198 PathPage
:=CreateCustomPage(
200 'Adjusting your PATH environment',
201 'How would you like to use Git from the command line?'
203 PrevPageID
:=PathPage
.ID
;
206 RdbPath
[GP_BashOnly
]:=TRadioButton
.Create(PathPage
);
207 with RdbPath
[GP_BashOnly
] do begin
208 Parent
:=PathPage
.Surface
;
209 Caption
:='Use Git Bash only';
214 Font
.Style
:=[fsBold
];
218 LblGitBash
:=TLabel
.Create(PathPage
);
219 with LblGitBash
do begin
220 Parent
:=PathPage
.Surface
;
222 'This is the most conservative choice if you are concerned about the stability' + #
13 +
223 'of your system. Your PATH will not be modified.';
231 RdbPath
[GP_Cmd
]:=TRadioButton
.Create(PathPage
);
232 with RdbPath
[GP_Cmd
] do begin
233 Parent
:=PathPage
.Surface
;
234 Caption
:='Run Git from the Windows Command Prompt';
239 Font
.Style
:=[fsBold
];
242 LblGitCmd
:=TLabel
.Create(PathPage
);
243 with LblGitCmd
do begin
244 Parent
:=PathPage
.Surface
;
246 'This option is considered safe and no conflicts with other tools are known.' + #
13 +
247 'Only Git will be added to your PATH. Use this option if you want to use Git' + #
13 +
248 'from a Cygwin Prompt (make sure to not have Cygwin''s Git installed).';
256 RdbPath
[GP_CmdTools
]:=TRadioButton
.Create(PathPage
);
257 with RdbPath
[GP_CmdTools
] do begin
258 Parent
:=PathPage
.Surface
;
259 Caption
:='Run Git and included Unix tools from the Windows Command Prompt';
264 Font
.Style
:=[fsBold
];
267 LblGitCmdTools
:=TLabel
.Create(PathPage
);
268 with LblGitCmdTools
do begin
269 Parent
:=PathPage
.Surface
;
270 Caption
:='Both Git and its accompanying Unix tools will be added to your PATH.';
276 LblGitCmdToolsWarn
:=TLabel
.Create(PathPage
);
277 with LblGitCmdToolsWarn
do begin
278 Parent
:=PathPage
.Surface
;
280 'Warning: This will override Windows tools like find.exe and' + #
13 +
281 'sort.exe. Select this option only if you understand the implications.';
287 Font
.Style
:=[fsBold
];
290 // Restore the setting chosen during a previous install
.
291 Data
:=GetPreviousData('Path Option','BashOnly');
292 if Data
='BashOnly' then begin
293 RdbPath
[GP_BashOnly
].Checked
:=True;
294 end else if Data
='Cmd' then begin
295 RdbPath
[GP_Cmd
].Checked
:=True;
296 end else if Data
='CmdTools' then begin
297 RdbPath
[GP_CmdTools
].Checked
:=True;
301 * Create a custom page for using (Tortoise)Plink instead of OpenSSH
302 * if at least one PuTTY session is found in the Registry.
305 if RegGetSubkeyNames(HKEY_CURRENT_USER
,'Software\SimonTatham\PuTTY\Sessions',PuTTYSessions
) and (GetArrayLength(PuTTYSessions
)>0) then begin
306 PuTTYPage
:=CreateCustomPage(
308 'Choosing the SSH executable',
309 'Which Secure Shell client program would you like Git to use?'
311 PrevPageID
:=PuTTYPage
.ID
;
314 RdbSSH
[GS_OpenSSH
]:=TRadioButton
.Create(PuTTYPage
);
315 with RdbSSH
[GS_OpenSSH
] do begin
316 Parent
:=PuTTYPage
.Surface
;
317 Caption
:='Use OpenSSH';
322 Font
.Style
:=[fsBold
];
326 LblOpenSSH
:=TLabel
.Create(PuTTYPage
);
327 with LblOpenSSH
do begin
328 Parent
:=PuTTYPage
.Surface
;
330 'This uses ssh.exe that comes with Git. The GIT_SSH and SVN_SSH' + #
13 +
331 'environment variables will not be modified.';
339 RdbSSH
[GS_Plink
]:=TRadioButton
.Create(PuTTYPage
);
340 with RdbSSH
[GS_Plink
] do begin
341 Parent
:=PuTTYPage
.Surface
;
342 Caption
:='Use (Tortoise)Plink';
347 Font
.Style
:=[fsBold
];
350 LblPlink
:=TLabel
.Create(PuTTYPage
);
351 with LblPlink
do begin
352 Parent
:=PuTTYPage
.Surface
;
354 'PuTTY sessions were found in your Registry. You may specify the path' + #
13 +
355 'to an existing copy of (Tortoise)Plink.exe from the TortoiseSVN/CVS' + #
13 +
356 'or PuTTY applications. The GIT_SSH and SVN_SSH environment' + #
13 +
357 'variables will be adjusted to point to the following executable:';
363 EdtPlink
:=TEdit
.Create(PuTTYPage
);
364 with EdtPlink
do begin
365 Parent
:=PuTTYPage
.Surface
;
366 Text:=GetPuTTYLocation
;
367 if not FileExists(Text) then begin
375 BtnPlink
:=TButton
.Create(PuTTYPage
);
376 with BtnPlink
do begin
377 Parent
:=PuTTYPage
.Surface
;
379 OnClick
:=@BrowseForPuTTYFolder
;
386 // Restore the setting chosen during a previous install
.
387 Data
:=GetPreviousData('SSH Option','OpenSSH');
388 if Data
='OpenSSH' then begin
389 RdbSSH
[GS_OpenSSH
].Checked
:=True;
390 end else if Data
='Plink' then begin
391 RdbSSH
[GS_Plink
].Checked
:=True;
398 * Create a custom page for the core.autocrlf setting.
401 CRLFPage
:=CreateCustomPage(
403 'Configuring the line ending conversions',
404 'How should Git treat line endings in text files?'
406 PrevPageID
:=CRLFPage
.ID
;
409 RdbCRLF
[GC_CRLFAlways
]:=TRadioButton
.Create(CRLFPage
);
410 with RdbCRLF
[GC_CRLFAlways
] do begin
411 Parent
:=CRLFPage
.Surface
;
412 Caption
:='Checkout Windows-style, commit Unix-style line endings';
417 Font
.Style
:=[fsBold
];
421 LblCRLFAlways
:=TLabel
.Create(CRLFPage
);
422 with LblCRLFAlways
do begin
423 Parent
:=CRLFPage
.Surface
;
425 'Git will convert LF to CRLF when checking out text files. When committing' + #
13 +
426 'text files, CRLF will be converted to LF. For cross-platform projects,' + #
13 +
427 'this is the recommended setting on Windows ("core.autocrlf" is set to "true").';
435 RdbCRLF
[GC_LFOnly
]:=TRadioButton
.Create(CRLFPage
);
436 with RdbCRLF
[GC_LFOnly
] do begin
437 Parent
:=CRLFPage
.Surface
;
438 Caption
:='Checkout as-is, commit Unix-style line endings';
443 Font
.Style
:=[fsBold
];
447 LblLFOnly
:=TLabel
.Create(CRLFPage
);
448 with LblLFOnly
do begin
449 Parent
:=CRLFPage
.Surface
;
451 'Git will not perform any conversion when checking out text files. When' + #
13 +
452 'committing text files, CRLF will be converted to LF. For cross-platform projects,' + #
13 +
453 'this is the recommended setting on Unix ("core.autocrlf" is set to "input").';
461 RdbCRLF
[GC_CRLFCommitAsIs
]:=TRadioButton
.Create(CRLFPage
);
462 with RdbCRLF
[GC_CRLFCommitAsIs
] do begin
463 Parent
:=CRLFPage
.Surface
;
464 Caption
:='Checkout as-is, commit as-is';
469 Font
.Style
:=[fsBold
];
473 LblCRLFCommitAsIs
:=TLabel
.Create(CRLFPage
);
474 with LblCRLFCommitAsIs
do begin
475 Parent
:=CRLFPage
.Surface
;
477 'Git will not perform any conversions when checking out or committing' + #
13 +
478 'text files. Choosing this option is not recommended for cross-platform' + #
13 +
479 'projects ("core.autocrlf" is set to "false").';
486 // Restore the setting chosen during a previous install
.
487 Data
:=GetPreviousData('CRLF Option','CRLFAlways');
488 if Data
='LFOnly' then begin
489 RdbCRLF
[GC_LFOnly
].Checked
:=True;
490 end else if Data
='CRLFAlways' then begin
491 RdbCRLF
[GC_CRLFAlways
].Checked
:=True;
492 end else if Data
='CRLFCommitAsIs' then begin
493 RdbCRLF
[GC_CRLFCommitAsIs
].Checked
:=True;
497 function NextButtonClick(CurPageID
:Integer):Boolean;
499 if (PuTTYPage
=NIL) or (CurPageID
<>PuTTYPage
.ID
) then begin
504 Result
:=RdbSSH
[GS_OpenSSH
].Checked
or
505 (RdbSSH
[GS_Plink
].Checked
and FileExists(EdtPlink
.Text));
507 if not Result
then begin
508 MsgBox('Please enter a valid path to (Tortoise)Plink.exe.',mbError
,MB_OK
);
514 // Even though the name
of this
procedure suggests otherwise most
of the
515 // code below
is only executed once after the regular installation code
516 // is finished
. This happens because
of the
if-guard right
in the
517 // beginning
of this
procedure.
518 procedure CurStepChanged(CurStep
:TSetupStep
);
520 AppDir
,FileName
,Cmd
,Msg
:String;
521 BuiltIns
,EnvPath
,EnvHome
,EnvSSH
:TArrayOfString
;
527 if CurStep
<>ssPostInstall
then begin
531 AppDir
:=ExpandConstant('{app}');
537 // Load the built
-ins from a
text file.
538 FileName
:=ExpandConstant('{app}\{#emit APP_BUILTINS}');
539 if LoadStringsFromFile(FileName
,BuiltIns
) then begin
540 Count
:=GetArrayLength(BuiltIns
)-1;
542 // Delete those scripts from
"bin" which have been replaced by built
-ins
in "libexec\git-core".
543 for i
:=0 to Count
do begin
544 FileName
:=AppDir
+'\bin\'+ChangeFileExt(ExtractFileName(BuiltIns[i]),'');
545 if FileExists(FileName) and (not DeleteFile(FileName)) then begin
546 Log('Line
{#emit __LINE__}: Unable
to delete script
"'+FileName+'", ignoring
.');
550 // Create built-ins as aliases for git.exe.
551 for i:=0 to Count do begin
552 FileName:=AppDir+'\'+BuiltIns
[i
];
554 // Delete any existing built
-in.
555 if FileExists(FileName
) and (not DeleteFile(FileName
)) then begin
556 Log('Line {#emit __LINE__}: Unable to delete existing built-in "'+FileName
+'", skipping.');
561 // This will throw an exception on pre
-WinVista systems
.
562 LinkCreated
:=CreateSymbolicLink(FileName
,AppDir
+'\bin\git.exe',0);
565 Log('Line {#emit __LINE__}: Creating symbolic link "'+FileName
+'" failed, will try a hard link.');
568 if not LinkCreated
then begin
570 // This will throw an exception on pre
-Win2k systems
.
571 LinkCreated
:=CreateHardLink(FileName
,AppDir
+'\bin\git.exe',0);
574 Log('Line {#emit __LINE__}: Creating hardlink "'+FileName
+'" failed, will try a copy.');
578 if not LinkCreated
then begin
579 if not FileCopy(AppDir
+'\bin\git.exe',FileName
,False) then begin
580 Log('Line {#emit __LINE__}: Creating copy "'+FileName
+'" failed, giving up.');
581 // This
is not a critical error
, Git could basically be used without the
582 // aliases
for built
-ins
, so we continue
.
587 // Delete any duplicate
files in case we are updating from a non
-libexec
to a libexec directory layout
.
588 if FindFirst(AppDir
+'\libexec\git-core\*',FindRec
) then begin
590 if (FindRec
.Attributes
and FILE_ATTRIBUTE_DIRECTORY
)=0 then begin
591 FileName
:=AppDir
+'\bin\'+FindRec.name;
592 if (Pos(FindRec.name,'git
.exe
')<>1) and FileExists(FileName) and (not DeleteFile(FileName)) then begin
593 Log('Line
{#emit __LINE__}: Unable
to delete dupe
"'+FileName+'", ignoring
.');
596 until not FindNext(FindRec);
600 Msg:='Line
{#emit __LINE__}: Unable
to read file "{#emit APP_BUILTINS}".';
601 MsgBox(Msg,mbError,MB_OK);
603 // This is not a critical error, Git could basically be used without the
604 // aliases for built-ins, so we continue.
611 if RdbCRLF[GC_LFOnly].checked then begin
612 Cmd:='core
.autocrlf input
';
613 end else if RdbCRLF[GC_CRLFAlways].checked then begin
614 Cmd:='core
.autocrlf
true';
616 Cmd:='core
.autocrlf
false';
618 if not Exec(AppDir + '\bin\git
.exe
', 'config
-f gitconfig
' + Cmd,
619 AppDir + '\etc
', SW_HIDE, ewWaitUntilTerminated, i) then begin
620 Msg:='Unable
to configure the line ending conversion
: ' + Cmd;
621 MsgBox(Msg,mbError,MB_OK);
626 Modify the environment
628 This must happen no later than ssPostInstall to make
629 "ChangesEnvironment=yes" not happend before the change!
632 FileName:=AppDir+'\setup
.ini
';
634 // Delete GIT_SSH and SVN_SSH if a previous installation set them (this is required for the GS_OpenSSH case).
635 EnvSSH:=GetEnvStrings('GIT_SSH
',IsAdminLoggedOn);
636 if (GetArrayLength(EnvSSH)=1) and
637 (CompareStr(RemoveQuotes(EnvSSH[0]),GetIniString('Environment
','GIT_SSH
','',FileName))=0) then begin
638 if not SetEnvStrings('GIT_SSH
',IsAdminLoggedOn,True,[]) then begin
639 Msg:='Line
{#emit __LINE__}: Unable
to reset GIT_SSH prior
to install
.';
640 MsgBox(Msg,mbError,MB_OK);
642 // This is not a critical error, the user can probably fix it manually,
647 EnvSSH:=GetEnvStrings('SVN_SSH
',IsAdminLoggedOn);
648 if (GetArrayLength(EnvSSH)=1) and
649 (CompareStr(RemoveQuotes(EnvSSH[0]),GetIniString('Environment
','SVN_SSH
','',FileName))=0) then begin
650 if not SetEnvStrings('SVN_SSH
',IsAdminLoggedOn,True,[]) then begin
651 Msg:='Line
{#emit __LINE__}: Unable
to reset SVN_SSH prior
to install
.';
652 MsgBox(Msg,mbError,MB_OK);
654 // This is not a critical error, the user can probably fix it manually,
659 if (PuTTYPage<>NIL) and RdbSSH[GS_Plink].Checked then begin
660 SetArrayLength(EnvSSH,1);
661 EnvSSH[0]:=EdtPlink.Text;
663 // Set GIT_SSH as specified by the user.
664 if not SetEnvStrings('GIT_SSH
',IsAdminLoggedOn,True,EnvSSH) then begin
665 Msg:='Line
{#emit __LINE__}: Unable
to set the GIT_SSH environment variable
.';
666 MsgBox(Msg,mbError,MB_OK);
668 // This is not a critical error, the user can probably fix it manually,
672 // Mark that we have changed GIT_SSH by writing its value to a file.
673 if not SetIniString('Environment
','GIT_SSH
',EnvSSH[0],FileName) then begin
674 Msg:='Line
{#emit __LINE__}: Unable
to write
to file "'+FileName+'".';
675 MsgBox(Msg,mbError,MB_OK);
677 // This is not a critical error, though uninstall / reinstall will probably not run cleanly,
681 // Set SVN_SSH as specified by the user, but with escaped backslashes and quotes.
682 StringChangeEx(EnvSSH[0],'\','\\',True);
683 EnvSSH
[0]:=AddQuotes(EnvSSH
[0]);
685 if not SetEnvStrings('SVN_SSH',IsAdminLoggedOn
,True,EnvSSH
) then begin
686 Msg
:='Line {#emit __LINE__}: Unable to set the SVN_SSH environment variable.';
687 MsgBox(Msg
,mbError
,MB_OK
);
689 // This
is not a critical error
, the user can probably fix it manually
,
693 // Mark that we have changed SVN_SSH by writing its value
to a
file.
694 if not SetIniString('Environment','SVN_SSH',EnvSSH
[0],FileName
) then begin
695 Msg
:='Line {#emit __LINE__}: Unable to write to file "'+FileName
+'".';
696 MsgBox(Msg
,mbError
,MB_OK
);
698 // This
is not a critical error
, though uninstall
/ reinstall will probably
not run cleanly
,
703 // Get the current user
's directories in PATH.
704 EnvPath:=GetEnvStrings('PATH
',IsAdminLoggedOn);
706 // First, remove the installation directory from PATH in any case.
707 for i:=0 to GetArrayLength(EnvPath)-1 do begin
708 if Pos(AppDir+'\',EnvPath
[i
]+'\')=1 then begin
713 // Delete HOME if a previous installation modified it.
714 EnvHome:=GetEnvStrings('HOME
',IsAdminLoggedOn);
715 if (GetArrayLength(EnvHome)=1) and
716 (CompareStr(RemoveQuotes(EnvHome[0]),GetIniString('Environment
','HOME
','',FileName))=0) then begin
717 if not SetEnvStrings('HOME
',IsAdminLoggedOn,True,[]) then begin
718 Msg:='Line
{#emit __LINE__}: Unable
to reset HOME prior
to install
.';
719 MsgBox(Msg,mbError,MB_OK);
721 // This is not a critical error, the user can probably fix it manually,
726 // Modify the PATH variable as requested by the user.
727 if RdbPath[GP_Cmd].Checked or RdbPath[GP_CmdTools].Checked then begin
728 i:=GetArrayLength(EnvPath);
729 SetArrayLength(EnvPath,i+1);
731 // List \cmd before \bin so \cmd has higher priority and programs in
732 // there will be called in favor of those in \bin.
733 EnvPath[i]:=ExpandConstant('{app}\cmd
');
735 if RdbPath[GP_CmdTools].Checked then begin
736 SetArrayLength(EnvPath,i+2);
737 EnvPath[i+1]:=ExpandConstant('{app}\bin
');
739 // Set HOME for the Windows Command Prompt, but only if it has not been set manually before.
740 EnvHome:=GetEnvStrings('HOME
',IsAdminLoggedOn);
741 i:=GetArrayLength(EnvHome);
742 if (i=0) or ((i=1) and (Length(EnvHome[0])=0)) then begin
743 SetArrayLength(EnvHome,1);
744 EnvHome[0]:=ExpandConstant('{%HOMEDRIVE}{%HOMEPATH}');
745 if not SetEnvStrings('HOME
',IsAdminLoggedOn,True,EnvHome) then begin
746 Msg:='Line
{#emit __LINE__}: Unable
to set the HOME environment variable
.';
747 MsgBox(Msg,mbError,MB_OK);
749 // This is not a critical error, the user can probably fix it manually,
753 // Mark that we have changed HOME.
754 if not SetIniString('Environment
','HOME
',EnvHome[0],FileName) then begin
755 Msg:='Line
{#emit __LINE__}: Unable
to write
to file "'+FileName+'".';
756 MsgBox(Msg,mbError,MB_OK);
758 // This is not a critical error, though uninstall / reinstall will probably not run cleanly,
765 // Set the current user's PATH directories
.
766 if not SetEnvStrings('PATH',IsAdminLoggedOn
,True,EnvPath
) then begin
767 Msg
:='Line {#emit __LINE__}: Unable to set the PATH environment variable.';
768 MsgBox(Msg
,mbError
,MB_OK
);
770 // This
is not a critical error
, the user can probably fix it manually
,
775 Create the Windows Explorer shell extensions
778 if IsAdminLoggedOn
then begin
779 RootKey
:=HKEY_LOCAL_MACHINE
;
781 RootKey
:=HKEY_CURRENT_USER
;
784 if IsComponentSelected('ext\shellhere') then begin
785 if (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_shell','','Git Ba&sh Here')) or
786 (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_shell\command','','wscript "'+AppDir
+'\Git Bash.vbs" "%1"')) then begin
787 Msg
:='Line {#emit __LINE__}: Unable to create "Git Bash Here" shell extension.';
788 MsgBox(Msg
,mbError
,MB_OK
);
790 // This
is not a critical error
, the user can probably fix it manually
,
795 if IsComponentSelected('ext\guihere') then begin
796 if (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_gui','','Git &GUI Here')) or
797 (not RegWriteStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_gui\command','','"'+AppDir
+'\bin\wish.exe" "'+AppDir
+'\libexec\git-core\git-gui" "--working-dir" "%1"')) then begin
798 Msg
:='Line {#emit __LINE__}: Unable to create "Git GUI Here" shell extension.';
799 MsgBox(Msg
,mbError
,MB_OK
);
801 // This
is not a critical error
, the user can probably fix it manually
,
807 procedure RegisterPreviousData(PreviousDataKey
:Integer);
813 if RdbPath
[GP_BashOnly
].Checked
then begin
815 end else if RdbPath
[GP_Cmd
].Checked
then begin
817 end else if RdbPath
[GP_CmdTools
].Checked
then begin
820 SetPreviousData(PreviousDataKey
,'Path Option',Data
);
824 if (PuTTYPage
=NIL) or RdbSSH
[GS_OpenSSH
].Checked
then begin
826 end else if RdbSSH
[GS_Plink
].Checked
then begin
829 SetPreviousData(PreviousDataKey
,'SSH Option',Data
);
831 // Line ending conversion options
.
833 if RdbCRLF
[GC_LFOnly
].Checked
then begin
835 end else if RdbCRLF
[GC_CRLFAlways
].Checked
then begin
837 end else if RdbCRLF
[GC_CRLFCommitAsIs
].Checked
then begin
838 Data
:='CRLFCommitAsIs';
840 SetPreviousData(PreviousDataKey
,'CRLF Option',Data
);
847 function InitializeUninstall
:Boolean;
849 FileName
,NewName
,Msg
:String;
851 FileName
:=ExpandConstant('{app}\bin\ssh-agent.exe');
852 if FileExists(FileName
) then begin
853 // Create a temporary copy
of the
file we
try to delete
.
854 NewName
:=FileName
+'.'+IntToStr(1000+Random(9000));
855 Result
:=FileCopy(FileName
,NewName
,True) and DeleteFile(FileName
);
857 if not Result
then begin
858 Msg
:='Line {#emit __LINE__}: Please stop all ssh-agent processes and run uninstall again.';
859 MsgBox(Msg
,mbError
,MB_OK
);
862 // Clean
-up the temporary
copy (ignoring any errors
).
865 // Clean
-up the temporary
copy (ignoring any errors
).
866 RenameFile(NewName
,FileName
);
875 // Even though the name
of this
function suggests otherwise most
of the
876 // code below
is only executed right before the actual uninstallation
.
877 // This happens because
of the
if-guard right
in the beginning
of this
879 procedure CurUninstallStepChanged(CurUninstallStep
:TUninstallStep
);
881 AppDir
,Command
,Msg
:String;
882 EnvPath
,EnvHome
,EnvSSH
:TArrayOfString
;
886 if CurUninstallStep
<>usUninstall
then begin
891 Modify the environment
893 This must happen no later than usUninstall to make
894 "ChangesEnvironment=yes" not happend before the change!
897 AppDir
:=ExpandConstant('{app}');
898 Command
:=AppDir
+'\setup.ini';
900 // Delete the current user
's GIT_SSH and SVN_SSH if we set it.
901 EnvSSH:=GetEnvStrings('GIT_SSH
',IsAdminLoggedOn);
902 if (GetArrayLength(EnvSSH)=1) and
903 (CompareStr(RemoveQuotes(EnvSSH[0]),GetIniString('Environment
','GIT_SSH
','',Command))=0) then begin
904 if not SetEnvStrings('GIT_SSH
',IsAdminLoggedOn,True,[]) then begin
905 Msg:='Line
{#emit __LINE__}: Unable
to revert any possible changes
to GIT_SSH
.';
906 MsgBox(Msg,mbError,MB_OK);
908 // This is not a critical error, the user can probably fix it manually,
913 EnvSSH:=GetEnvStrings('SVN_SSH
',IsAdminLoggedOn);
914 if (GetArrayLength(EnvSSH)=1) and
915 (CompareStr(RemoveQuotes(EnvSSH[0]),GetIniString('Environment
','SVN_SSH
','',Command))=0) then begin
916 if not SetEnvStrings('SVN_SSH
',IsAdminLoggedOn,True,[]) then begin
917 Msg:='Line
{#emit __LINE__}: Unable
to revert any possible changes
to SVN_SSH
.';
918 MsgBox(Msg,mbError,MB_OK);
920 // This is not a critical error, the user can probably fix it manually,
925 // Get the current user's directories
in PATH
.
926 EnvPath
:=GetEnvStrings('PATH',IsAdminLoggedOn
);
928 // Remove the installation directory from PATH
in any
case, even
if it
929 // was
not added by the installer
.
930 for i
:=0 to GetArrayLength(EnvPath
)-1 do begin
931 if Pos(AppDir
+'\',EnvPath[i]+'\')=1 then begin
936 // Reset the current user
's directories in PATH.
937 if not SetEnvStrings('PATH
',IsAdminLoggedOn,True,EnvPath) then begin
938 Msg:='Line
{#emit __LINE__}: Unable
to revert any possible changes
to PATH
.';
939 MsgBox(Msg,mbError,MB_OK);
941 // This is not a critical error, the user can probably fix it manually,
945 // Reset the current user's HOME
if we modified it
.
946 EnvHome
:=GetEnvStrings('HOME',IsAdminLoggedOn
);
947 if (GetArrayLength(EnvHome
)=1) and
948 (CompareStr(RemoveQuotes(EnvHome
[0]),GetIniString('Environment','HOME','',Command
))=0) then begin
949 if not SetEnvStrings('HOME',IsAdminLoggedOn
,True,[]) then begin
950 Msg
:='Line {#emit __LINE__}: Unable to revert any possible changes to HOME.';
951 MsgBox(Msg
,mbError
,MB_OK
);
953 // This
is not a critical error
, the user can probably fix it manually
,
958 if FileExists(Command
) and (not DeleteFile(Command
)) then begin
959 Msg
:='Line {#emit __LINE__}: Unable to delete file "'+Command
+'".';
960 MsgBox(Msg
,mbError
,MB_OK
);
962 // This
is not a critical error
, the user can probably fix it manually
,
967 Delete the Windows Explorer shell extensions
970 if IsAdminLoggedOn
then begin
971 RootKey
:=HKEY_LOCAL_MACHINE
;
973 RootKey
:=HKEY_CURRENT_USER
;
977 RegQueryStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_shell\command','',Command
);
978 if Pos(AppDir
,Command
)>0 then begin
979 if not RegDeleteKeyIncludingSubkeys(RootKey
,'SOFTWARE\Classes\Directory\shell\git_shell') then begin
980 Msg
:='Line {#emit __LINE__}: Unable to remove "Git Bash Here" shell extension.';
981 MsgBox(Msg
,mbError
,MB_OK
);
983 // This
is not a critical error
, the user can probably fix it manually
,
989 RegQueryStringValue(RootKey
,'SOFTWARE\Classes\Directory\shell\git_gui\command','',Command
);
990 if Pos(AppDir
,Command
)>0 then begin
991 if not RegDeleteKeyIncludingSubkeys(RootKey
,'SOFTWARE\Classes\Directory\shell\git_gui') then begin
992 Msg
:='Line {#emit __LINE__}: Unable to remove "Git GUI Here" shell extension.';
993 MsgBox(Msg
,mbError
,MB_OK
);
995 // This
is not a critical error
, the user can probably fix it manually
,