Skip to content

Commit 5a95abc

Browse files
committed
installer: do not bother with C:\ProgramData\Git\config anymore
In git-for-windows/git#2358, we reconciled the two system configs into a single one. Even if we now build an installer bundling a Git executable that is still ProgramData-aware, it does not hurt to already drop bothering about editing/initializing it: the system config in `C:\Program Files` would override the ProgramData one anyway. Note: for the time being, we still initialize the defaults for the settings that can be configured in Git for Windows' installer from _both_ ProgramData _and_ the previous installation's system config. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e628272 commit 5a95abc

File tree

3 files changed

+18
-71
lines changed

3 files changed

+18
-71
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ edit-git-bash.exe
1717
/installer/is-unicode.exe
1818
/installer/file-list.iss
1919
/installer/package-versions.txt
20-
/installer/programdata-config.template
2120
/installer/root/
2221
/mingit/exclude-list
2322
/mingit/root/

installer/install.iss

Lines changed: 15 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,6 @@ end;
21842184
procedure CleanupWhenUpgrading;
21852185
var
21862186
ErrorCode:Integer;
2187-
ProgramData:String;
21882187
begin
21892188
if UninstallAppPath<>'' then begin
21902189
// Save a copy of the system config so that we can copy it back later
@@ -2195,15 +2194,6 @@ begin
21952194
end else if FileExists(UninstallAppPath+'\etc\gitconfig') and
21962195
(not FileCopy(UninstallAppPath+'\etc\gitconfig',ExpandConstant('{tmp}\gitconfig.system'),True)) then
21972196
LogError('Could not save system config; continuing anyway');
2198-
2199-
ProgramData:=ExpandConstant('{commonappdata}');
2200-
if FileExists(UninstallAppPath+'\etc\gitconfig') and not FileExists(ProgramData+'\Git\config') then begin
2201-
if not ForceDirectories(ProgramData+'\Git') then
2202-
LogError('Could not initialize Windows-wide Git config.')
2203-
else if not FileCopy(UninstallAppPath+'\etc\gitconfig',ProgramData+'\Git\config',False) then
2204-
LogError('Could not copy old Git config to Windows-wide location.');
2205-
end;
2206-
22072197
end;
22082198
22092199
if UninstallString<>'' then begin
@@ -2371,7 +2361,7 @@ end;
23712361
23722362
procedure CurStepChanged(CurStep:TSetupStep);
23732363
var
2374-
ProgramData,DllPath,FileName,Cmd,Msg,Ico:String;
2364+
DllPath,FileName,Cmd,Msg,Ico:String;
23752365
BuiltIns,ImageNames,EnvPath:TArrayOfString;
23762366
Count,i:Longint;
23772367
RootKey:Integer;
@@ -2398,7 +2388,6 @@ begin
23982388
end;
23992389
24002390
AppDir:=ExpandConstant('{app}');
2401-
ProgramData:=ExpandConstant('{commonappdata}');
24022391
24032392
{
24042393
Copy dlls from "/mingw64/bin" to "/mingw64/libexec/git-core" if they are
@@ -2471,20 +2460,6 @@ begin
24712460
end else
24722461
LogError('Line {#__LINE__}: Unable to read file "{#MINGW_BITNESS}\{#APP_BUILTINS}".');
24732462
2474-
// Create default ProgramData git config file
2475-
if not FileExists(ProgramData + '\Git\config') then begin
2476-
if not DirExists(ProgramData + '\Git') then begin
2477-
if not CreateDir(ProgramData + '\Git') then begin
2478-
Log('Line {#__LINE__}: Creating directory "' + ProgramData + '\Git" failed.');
2479-
end;
2480-
end;
2481-
if not FileExists(ExpandConstant('{tmp}\programdata-config.template')) then
2482-
ExtractTemporaryFile('programdata-config.template');
2483-
if not FileCopy(ExpandConstant('{tmp}\programdata-config.template'), ProgramData + '\Git\config', True) then begin
2484-
Log('Line {#__LINE__}: Creating initial "' + ProgramData + '\Git\config" failed.');
2485-
end;
2486-
end;
2487-
24882463
// Copy previous system wide git config file, if any
24892464
if FileExists(ExpandConstant('{tmp}\gitconfig.system')) then begin
24902465
if (not ForceDirectories(AppDir+'\{#ETC_GITCONFIG_DIR}')) then
@@ -2509,35 +2484,25 @@ begin
25092484
else
25102485
GitSystemConfigSet('http.sslBackend','openssl');
25112486
2512-
if FileExists(ProgramData+'\Git\config') then begin
2513-
if not Exec(AppDir+'\bin\bash.exe','-c "value=\"$(git config -f config pack.packsizelimit)\" && if test 2g = \"$value\"; then git config -f config --unset pack.packsizelimit; fi"',ProgramData+'\Git',SW_HIDE,ewWaitUntilTerminated,i) then
2514-
LogError('Unable to remove packsize limit from ProgramData config');
2515-
Cmd:=AppDir+'/';
2487+
if not RdbCurlVariant[GC_WinSSL].Checked then begin
2488+
Cmd:=AppDir+'/{#MINGW_BITNESS}/ssl/certs/ca-bundle.crt';
25162489
StringChangeEx(Cmd,'\','/',True);
2517-
if not Exec(AppDir+'\bin\bash.exe','-c "value=\"$(git config -f config http.sslcainfo)\" && case \"$value\" in \"'+Cmd+'\"/*|\"C:/Program Files/Git/\"*|\"c:/Program Files/Git/\"*) git config -f config --unset http.sslcainfo;; esac"',ProgramData+'\Git',SW_HIDE,ewWaitUntilTerminated,i) then
2518-
LogError('Unable to delete http.sslCAInfo from ProgramData config');
2519-
if not RdbCurlVariant[GC_WinSSL].Checked then begin
2520-
Cmd:=AppDir+'/{#MINGW_BITNESS}/ssl/certs/ca-bundle.crt';
2521-
StringChangeEx(Cmd,'\','/',True);
2522-
GitSystemConfigSet('http.sslCAInfo',Cmd);
2523-
end else
2524-
GitSystemConfigSet('http.sslCAInfo',#0);
2525-
end;
2490+
GitSystemConfigSet('http.sslCAInfo',Cmd);
2491+
end else
2492+
GitSystemConfigSet('http.sslCAInfo',#0);
25262493
25272494
{
25282495
Adapt core.autocrlf
25292496
}
25302497
25312498
if RdbCRLF[GC_LFOnly].checked then begin
2532-
Cmd:='core.autocrlf input';
2499+
Cmd:='input';
25332500
end else if RdbCRLF[GC_CRLFAlways].checked then begin
2534-
Cmd:='core.autocrlf true';
2501+
Cmd:='true';
25352502
end else begin
2536-
Cmd:='core.autocrlf false';
2503+
Cmd:='false';
25372504
end;
2538-
if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe', 'config -f config ' + Cmd,
2539-
ProgramData + '\Git', SW_HIDE, ewWaitUntilTerminated, i) then
2540-
LogError('Unable to configure the line ending conversion: ' + Cmd);
2505+
GitSystemConfigSet('core.autocrlf',Cmd);
25412506
25422507
{
25432508
Configure the terminal window for Git Bash
@@ -2551,24 +2516,17 @@ begin
25512516
Configure extra options
25522517
}
25532518
2554-
if RdbExtraOptions[GP_FSCache].checked then begin
2555-
Cmd:='core.fscache true';
2556-
2557-
if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe', 'config -f config ' + Cmd,
2558-
ProgramData + '\Git', SW_HIDE, ewWaitUntilTerminated, i) then
2559-
LogError('Unable to enable the extra option: ' + Cmd);
2560-
end;
2519+
if RdbExtraOptions[GP_FSCache].checked then
2520+
GitSystemConfigSet('core.fscache','true');
25612521
25622522
if RdbExtraOptions[GP_GCM].checked then
25632523
GitSystemConfigSet('credential.helper','manager');
25642524
25652525
if RdbExtraOptions[GP_Symlinks].checked then
2566-
Cmd:='core.symlinks true'
2526+
Cmd:='true'
25672527
else
2568-
Cmd:='core.symlinks false';
2569-
if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe', 'config -f config ' + Cmd,
2570-
ProgramData + '\Git', SW_HIDE, ewWaitUntilTerminated, i) then
2571-
LogError('Unable to enable the extra option: ' + Cmd);
2528+
Cmd:='false';
2529+
GitSystemConfigSet('core.symlinks',Cmd);
25722530
25732531
{
25742532
Configure experimental options

installer/release.sh

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,17 @@ then
162162
fi
163163

164164
GITCONFIG_PATH="$(echo "$LIST" | grep "^mingw$BITNESS/etc/gitconfig\$")"
165-
printf '' >programdata-config.template
166165
test -z "$GITCONFIG_PATH" || {
167-
cp "/$GITCONFIG_PATH" programdata-config.template &&
168-
keys="$(git config -f programdata-config.template -l --name-only)" &&
166+
keys="$(git config -f "/$GITCONFIG_PATH" -l --name-only)" &&
169167
gitconfig="$LF[Code]${LF}function GitSystemConfigSet(Key,Value:String):Boolean; forward;$LF" &&
170168
gitconfig="$gitconfig${LF}function SetSystemConfigDefaults():Boolean;${LF}begin${LF} Result:=True;${LF}" &&
171169
for key in $keys
172170
do
173171
case "$key" in
174172
pack.packsizelimit|diff.astextplain.*|filter.lfs.*|http.sslcainfo)
175173
# set in the system-wide config
176-
value="$(git config -f programdata-config.template "$key")" &&
174+
value="$(git config -f "/$GITCONFIG_PATH" "$key")" &&
177175
case "$key$value" in *"'"*) die "Cannot handle $key=$value because of the single quote";; esac &&
178-
git config -f programdata-config.template --unset "$key" &&
179176
case "$key" in
180177
filter.lfs.*) extra=" IsComponentSelected('gitlfs') And";;
181178
pack.packsizelimit) test $BITNESS = 32 || continue; value=2g;;
@@ -185,9 +182,7 @@ test -z "$GITCONFIG_PATH" || {
185182
break
186183
;;
187184
esac || break
188-
done &&
189-
sed -i '/^\[/{:1;$d;N;/^.[^[]*$/b;s/^.*\[/[/;b1}' \
190-
programdata-config.template ||
185+
done ||
191186
die "Could not split gitconfig"
192187

193188
gitconfig="$gitconfig${LF}end;$LF"
@@ -196,11 +191,6 @@ test -z "$GITCONFIG_PATH" || {
196191
LIST="$(echo "$LIST" | grep -v "^$GITCONFIG_PATH\$")"
197192
}
198193

199-
printf '%s\n' \
200-
'Source: {#SourcePath}\programdata-config.template; Flags: dontcopy' \
201-
>>file-list.iss ||
202-
die "Could not append gitconfig to file list"
203-
204194
test -z "$LIST" ||
205195
echo "$LIST" |
206196
sed -e 's|/|\\|g' \

0 commit comments

Comments
 (0)