diff --git a/.gitignore b/.gitignore index 84b5c5f09b..2cb0133d83 100644 --- a/.gitignore +++ b/.gitignore @@ -10,10 +10,12 @@ edit-git-bash.exe /installer/ReleaseNotes.html /installer/bindimage.txt /installer/config.iss +/installer/gitconfig.system /installer/install.log /installer/is-unicode.exe /installer/file-list.iss /installer/package-versions.txt +/installer/programdata-config.template /mingit/exclude-list /mingit/root/ /mingit/sorted-all diff --git a/installer/install.iss b/installer/install.iss index 9d131dd663..e1eef574de 100644 --- a/installer/install.iss +++ b/installer/install.iss @@ -1839,8 +1839,10 @@ begin Log('Line {#__LINE__}: Creating directory "' + ProgramData + '\Git" failed.'); end; end; - if not FileCopy(AppDir + '\{#MINGW_BITNESS}\etc\gitconfig', ProgramData + '\Git\config', True) then begin - Log('Line {#__LINE__}: Creating copy "' + ProgramData + '\Git\config" failed.'); + if not FileExists(ExpandConstant('{tmp}\programdata-config.template')) then + ExtractTemporaryFile('programdata-config.template'); + if not FileCopy(ExpandConstant('{tmp}\programdata-config.template'), ProgramData + '\Git\config', True) then begin + Log('Line {#__LINE__}: Creating initial "' + ProgramData + '\Git\config" failed.'); end; end; if FileExists(ProgramData+'\Git\config') then begin @@ -1853,9 +1855,6 @@ begin if not Exec(AppDir+'\{#MINGW_BITNESS}\bin\git.exe','config -f config '+Cmd, ProgramData+'\Git',SW_HIDE,ewWaitUntilTerminated,i) then LogError('Unable to configure SSL CA info: ' + Cmd); - if not DeleteFile(AppDir+'\{#MINGW_BITNESS}\etc\gitconfig') then begin - Log('Line {#__LINE__}: Deleting template config "' + AppDir + '\{#MINGW_BITNESS}\etc\gitconfig" failed.'); - end; end; { diff --git a/installer/release.sh b/installer/release.sh index 3f67fcacd6..0da4dda2b1 100755 --- a/installer/release.sh +++ b/installer/release.sh @@ -124,6 +124,50 @@ case "$LIST" in ;; esac +GITCONFIG_PATH="$(echo "$LIST" | grep "^mingw$BITNESS/etc/gitconfig\$")" +printf '' >programdata-config.template +test -z "$GITCONFIG_PATH" || { + cp "/$GITCONFIG_PATH" gitconfig.system && + cp "/$GITCONFIG_PATH" programdata-config.template && + keys="$(git config -f gitconfig.system -l --name-only)" && + for key in $keys + do + case "$key" in + pack.packsizelimit) + # remove from both, will be configured by installer + git config -f programdata-config.template \ + --unset "$key" && + git config -f gitconfig.system --unset "$key" || + break + ;; + diff.astextplain.*|filter.lfs.*|http.sslcainfo) + # keep in the system-wide config + git config -f programdata-config.template \ + --unset "$key" || + break + ;; + *) + # move to the ProgramData template + git config -f gitconfig.system --unset "$key" || + break + ;; + esac || break + done && + sed -i '/^\[/{:1;$d;N;/^.[^[]*$/b;s/^.*\[/[/;b1}' gitconfig.system && + sed -i '/^\[/{:1;$d;N;/^.[^[]*$/b;s/^.*\[/[/;b1}' \ + programdata-config.template || + die "Could not split gitconfig" + LIST="$(echo "$LIST" | grep -v "^$GITCONFIG_PATH\$")" +} + +printf '%s%s%s\n%s\n' \ + 'Source: {#SourcePath}\gitconfig.system; DestName: gitconfig; ' \ + "DestDir: {app}\\mingw$BITNESS\\etc; Flags: replacesameversion; " \ + 'AfterInstall: DeleteFromVirtualStore' \ + 'Source: {#SourcePath}\programdata-config.template; Flags: dontcopy' \ + >>file-list.iss || +die "Could not append gitconfig to file list" + test -z "$LIST" || echo "$LIST" | sed -e 's|/|\\|g' \