Skip to content

Commit

Permalink
installer: retain system config across upgrades
Browse files Browse the repository at this point in the history
In particular in complex setups like VFS for Git, where Git for Windows
is just one installed component, it does makes sense for 3rd-party
software to configure settings in Git for Windows' system config.

In such scenarios, those settings should be retained between Git for
Windows upgrades as much as possible.

So lets' do that.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 20, 2019
1 parent e1e83d7 commit 646b6e2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,11 @@ var
ProgramData:String;
begin
if UninstallAppPath<>'' then begin
// Save a copy of the system config so that we can copy it back later
if FileExists(UninstallAppPath+'\{#MINGW_BITNESS}\etc\gitconfig') and
(not FileCopy(UninstallAppPath+'\{#MINGW_BITNESS}\etc\gitconfig',ExpandConstant('{tmp}\gitconfig.system'),True)) then
LogError('Could not save system config; continuing anyway');
ProgramData:=ExpandConstant('{commonappdata}');
if FileExists(UninstallAppPath+'\etc\gitconfig') and not FileExists(ProgramData+'\Git\config') then begin
if not ForceDirectories(ProgramData+'\Git') then
Expand All @@ -2138,8 +2143,6 @@ begin
LogError('Could not copy old Git config to Windows-wide location.');
end;
if FileExists(UninstallAppPath+'\{#MINGW_BITNESS}\etc\gitconfig') then begin
end;
end;
if UninstallString<>'' then begin
Expand Down Expand Up @@ -2352,7 +2355,7 @@ begin
end else
LogError('Line {#__LINE__}: Unable to read file "{#MINGW_BITNESS}\{#APP_BUILTINS}".');
// Create default system wide git config file
// Create default ProgramData git config file
if not FileExists(ProgramData + '\Git\config') then begin
if not DirExists(ProgramData + '\Git') then begin
if not CreateDir(ProgramData + '\Git') then begin
Expand All @@ -2366,6 +2369,14 @@ begin
end;
end;
// Copy previous system wide git config file, if any
if FileExists(ExpandConstant('{tmp}\gitconfig.system')) then begin
if (not ForceDirectories(AppDir+'\{#MINGW_BITNESS}\etc')) then
LogError('Failed to create \{#MINGW_BITNESS}\etc; continuing anyway')
else
FileCopy(ExpandConstant('{tmp}\gitconfig.system'),AppDir+'\{#MINGW_BITNESS}\etc\gitconfig',True)
end;
{
Configure http.sslBackend according to the user's choice.
}
Expand Down

0 comments on commit 646b6e2

Please sign in to comment.