From 646b6e22599f81f1d5a83074cbe08782bac51ad0 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 20 Feb 2019 13:52:05 +0100 Subject: [PATCH] installer: retain system config across upgrades 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 --- installer/install.iss | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/installer/install.iss b/installer/install.iss index fd016a4925..fc5a38a628 100644 --- a/installer/install.iss +++ b/installer/install.iss @@ -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 @@ -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 @@ -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 @@ -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. }