Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update installer/portable/mingit for the new system config location #262

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ edit-git-bash.exe
/git-for-windows-keyring/git-for-windows-keyring-*.src.tar.gz
/installer/ReleaseNotes.html
/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
/installer/root/
/mingit/exclude-list
/mingit/root/
Expand Down
3 changes: 3 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ This package contains software from a number of other projects including Bash, z

## Changes since Git for Windows v2.23.0 (August 17th 2019)

Note! As a consequence of making `git config --system` work as expected, the location of the system config is now `C:\Program Files\Git\etc\gitconfig` (no longer split between `C:\Program Files\Git\mingw64\etc\gitconfig` and `C:\ProgramData\Git\config`), and likewise the location of the system gitattributes is now `C:\Program Files\Git\etc\gitattributes` (no longer `C:\Program Files\Git\mingw64\etc\gitattributes`). Any manual modifications to `C:\ProgramData\Git\config` need to be ported manually.

### New Features

* Comes with [cURL v7.66.0](https://curl.haxx.se/changes.html#7_66_0).
Expand All @@ -48,6 +50,7 @@ This package contains software from a number of other projects including Bash, z
* The default config [no longer skips `git-lfs` downloads](https://github.com/git-for-windows/build-extra/pull/256).
* Starting with cURL v7.66.0, [`$HOME/.netrc` can be used](https://github.com/curl/curl/commit/f9c7ba9096ec29db2536481d8e9ebe314e007f0c) instead of `$HOME/_netrc` (but it will still fall back to looking for the latter).
* The installer's "ProductVersion" [is now consistent with older Git for Windows versions'](https://github.com/git-for-windows/build-extra/pull/257).
* [Makes `git config --system` work like you think it should](https://github.com/git-for-windows/git/pull/2358).

## Changes since Git for Windows v2.22.0 (June 8th 2019)

Expand Down
24 changes: 12 additions & 12 deletions git-extra/git-extra.install.in
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
export LC_ALL=C

post_install () {
for dir in mingw32 mingw64
do
test ! -d /$dir ||
test -f /$dir/etc/gitconfig ||
cat > /$dir/etc/gitconfig <<\GITCONFIG
ETC_GITCONFIG="$(git -c core.editor=echo config --system -e 2>/dev/null)"
test -f "$ETC_GITCONFIG" ||
cat > "$ETC_GITCONFIG" <<\GITCONFIG
@@GITCONFIG@@
GITCONFIG
test ! -d /$dir ||
test -f /$dir/etc/gitattributes ||
cat > /$dir/etc/gitattributes <<\GITATTRIBUTES
ETC_GITATTRIBUTES="${ETC_GITCONFIG%/*}/gitattributes"
test -f "$ETC_GITATTRIBUTES" ||
cat > "$ETC_GITATTRIBUTES" <<\GITATTRIBUTES
@@GITATTRIBUTES@@

GITATTRIBUTES

grep -q '^\*\.docm' /$dir/etc/gitattributes ||
sed -i -e 's/^\*\.DOCX\(.*\)/&\n*.docm\1\n*.DOCM\1/' \
-e 's/^\*\.DOT\(.*\)/&\n*.dotm\1\n*.DOTM\1/' \
/$dir/etc/gitattributes
grep -q '^\*\.docm' "$ETC_GITATTRIBUTES" ||
sed -i -e 's/^\*\.DOCX\(.*\)/&\n*.docm\1\n*.DOCM\1/' \
-e 's/^\*\.DOT\(.*\)/&\n*.dotm\1\n*.DOTM\1/' \
"$ETC_GITATTRIBUTES"

for dir in mingw32 mingw64
do
# Drop git-wrapper in place of builtins "to save space"
git_wrapper=/$dir/share/git/git-wrapper.exe
if test -f $git_wrapper &&
Expand Down
86 changes: 24 additions & 62 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2184,22 +2184,16 @@ end;
procedure CleanupWhenUpgrading;
var
ErrorCode:Integer;
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
if FileExists(UninstallAppPath+'\{#MINGW_BITNESS}\etc\gitconfig') then begin
if (not FileCopy(UninstallAppPath+'\{#MINGW_BITNESS}\etc\gitconfig',ExpandConstant('{tmp}\gitconfig.system'),True)) then
LogError('Could not save system config; continuing anyway');
// Save a copy of the system config so that we can copy it back later
end else if FileExists(UninstallAppPath+'\etc\gitconfig') and
(not FileCopy(UninstallAppPath+'\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
LogError('Could not initialize Windows-wide Git config.')
else if not FileCopy(UninstallAppPath+'\etc\gitconfig',ProgramData+'\Git\config',False) then
LogError('Could not copy old Git config to Windows-wide location.');
end;

end;

if UninstallString<>'' then begin
Expand Down Expand Up @@ -2367,7 +2361,7 @@ end;

procedure CurStepChanged(CurStep:TSetupStep);
var
ProgramData,DllPath,FileName,Cmd,Msg,Ico:String;
DllPath,FileName,Cmd,Msg,Ico:String;
BuiltIns,ImageNames,EnvPath:TArrayOfString;
Count,i:Longint;
RootKey:Integer;
Expand All @@ -2394,7 +2388,6 @@ begin
end;

AppDir:=ExpandConstant('{app}');
ProgramData:=ExpandConstant('{commonappdata}');

{
Copy dlls from "/mingw64/bin" to "/mingw64/libexec/git-core" if they are
Expand Down Expand Up @@ -2467,26 +2460,12 @@ begin
end else
LogError('Line {#__LINE__}: Unable to read file "{#MINGW_BITNESS}\{#APP_BUILTINS}".');

// 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
Log('Line {#__LINE__}: Creating directory "' + ProgramData + '\Git" failed.');
end;
end;
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;

// 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')
if (not ForceDirectories(AppDir+'\{#ETC_GITCONFIG_DIR}')) then
LogError('Failed to create \{#ETC_GITCONFIG_DIR}; continuing anyway')
else
FileCopy(ExpandConstant('{tmp}\gitconfig.system'),AppDir+'\{#MINGW_BITNESS}\etc\gitconfig',True)
FileCopy(ExpandConstant('{tmp}\gitconfig.system'),AppDir+'\{#ETC_GITCONFIG_DIR}\gitconfig',True)
end;

{
Expand All @@ -2505,35 +2484,25 @@ begin
else
GitSystemConfigSet('http.sslBackend','openssl');

if FileExists(ProgramData+'\Git\config') then begin
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
LogError('Unable to remove packsize limit from ProgramData config');
Cmd:=AppDir+'/';
if not RdbCurlVariant[GC_WinSSL].Checked then begin
Cmd:=AppDir+'/{#MINGW_BITNESS}/ssl/certs/ca-bundle.crt';
StringChangeEx(Cmd,'\','/',True);
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
LogError('Unable to delete http.sslCAInfo from ProgramData config');
if not RdbCurlVariant[GC_WinSSL].Checked then begin
Cmd:=AppDir+'/{#MINGW_BITNESS}/ssl/certs/ca-bundle.crt';
StringChangeEx(Cmd,'\','/',True);
GitSystemConfigSet('http.sslCAInfo',Cmd);
end else
GitSystemConfigSet('http.sslCAInfo',#0);
end;
GitSystemConfigSet('http.sslCAInfo',Cmd);
end else
GitSystemConfigSet('http.sslCAInfo',#0);

{
Adapt core.autocrlf
}

if RdbCRLF[GC_LFOnly].checked then begin
Cmd:='core.autocrlf input';
Cmd:='input';
end else if RdbCRLF[GC_CRLFAlways].checked then begin
Cmd:='core.autocrlf true';
Cmd:='true';
end else begin
Cmd:='core.autocrlf false';
Cmd:='false';
end;
if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe', 'config -f config ' + Cmd,
ProgramData + '\Git', SW_HIDE, ewWaitUntilTerminated, i) then
LogError('Unable to configure the line ending conversion: ' + Cmd);
GitSystemConfigSet('core.autocrlf',Cmd);

{
Configure the terminal window for Git Bash
Expand All @@ -2547,24 +2516,17 @@ begin
Configure extra options
}

if RdbExtraOptions[GP_FSCache].checked then begin
Cmd:='core.fscache true';

if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe', 'config -f config ' + Cmd,
ProgramData + '\Git', SW_HIDE, ewWaitUntilTerminated, i) then
LogError('Unable to enable the extra option: ' + Cmd);
end;
if RdbExtraOptions[GP_FSCache].checked then
GitSystemConfigSet('core.fscache','true');

if RdbExtraOptions[GP_GCM].checked then
GitSystemConfigSet('credential.helper','manager');

if RdbExtraOptions[GP_Symlinks].checked then
Cmd:='core.symlinks true'
Cmd:='true'
else
Cmd:='core.symlinks false';
if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe', 'config -f config ' + Cmd,
ProgramData + '\Git', SW_HIDE, ewWaitUntilTerminated, i) then
LogError('Unable to enable the extra option: ' + Cmd);
Cmd:='false';
GitSystemConfigSet('core.symlinks',Cmd);

{
Configure experimental options
Expand Down
30 changes: 14 additions & 16 deletions installer/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ echo "Compiling edit-git-bash.exe ..."
make -C ../ edit-git-bash.exe ||
die "Could not build edit-git-bash.exe"

etc_gitconfig="$(git -c core.editor=echo config --system -e 2>/dev/null)" &&
etc_gitconfig="$(cygpath -au "$etc_gitconfig")" &&
etc_gitconfig="${etc_gitconfig#/}" ||
die "Could not determine the path of the system config"

if test t = "$skip_files"
then
# make sure the file exists, as the installer wants it
Expand All @@ -107,6 +112,7 @@ then
else
echo "Generating file list to be included in the installer ..."
LIST="$(ARCH=$ARCH BITNESS=$BITNESS \
ETC_GITCONFIG="$etc_gitconfig" \
PACKAGE_VERSIONS_FILE=package-versions.txt \
INCLUDE_GIT_UPDATE=1 \
sh ../make-file-list.sh)" ||
Expand Down Expand Up @@ -156,33 +162,28 @@ then
inno_defines="$inno_defines$LF#define WITH_EXPERIMENTAL_BUILTIN_ADD_I 1"
fi

GITCONFIG_PATH="$(echo "$LIST" | grep "^mingw$BITNESS/etc/gitconfig\$")"
printf '' >programdata-config.template
GITCONFIG_PATH="$(echo "$LIST" | grep "^$etc_gitconfig\$")"
test -z "$GITCONFIG_PATH" || {
cp "/$GITCONFIG_PATH" programdata-config.template &&
keys="$(git config -f programdata-config.template -l --name-only)" &&
keys="$(git config -f "/$GITCONFIG_PATH" -l --name-only)" &&
gitconfig="$LF[Code]${LF}function GitSystemConfigSet(Key,Value:String):Boolean; forward;$LF" &&
gitconfig="$gitconfig${LF}function SetSystemConfigDefaults():Boolean;${LF}begin${LF} Result:=True;${LF}" &&
for key in $keys
do
case "$key" in
pack.packsizelimit|diff.astextplain.*|filter.lfs.*|http.sslcainfo)
# set in the system-wide config
value="$(git config -f programdata-config.template "$key")" &&
value="$(git config -f "/$GITCONFIG_PATH" "$key")" &&
case "$key$value" in *"'"*) die "Cannot handle $key=$value because of the single quote";; esac &&
git config -f programdata-config.template --unset "$key" &&
case "$key" in
filter.lfs.*) extra=" IsComponentSelected('gitlfs') And";;
pack.packsizelimit) test $BITNESS = 32 || continue; value=2g;;
pack.packsizelimit) test $BITNESS = 32 || continue; value=2g; extra=;;
*) extra=;;
esac &&
gitconfig="$gitconfig$LF if$extra not GitSystemConfigSet('$key','$value') then$LF Result:=False;" ||
break
;;
esac || break
done &&
sed -i '/^\[/{:1;$d;N;/^.[^[]*$/b;s/^.*\[/[/;b1}' \
programdata-config.template ||
done ||
die "Could not split gitconfig"

gitconfig="$gitconfig${LF}end;$LF"
Expand All @@ -191,11 +192,6 @@ test -z "$GITCONFIG_PATH" || {
LIST="$(echo "$LIST" | grep -v "^$GITCONFIG_PATH\$")"
}

printf '%s\n' \
'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' \
Expand All @@ -215,11 +211,13 @@ test -z "$include_pdbs" || {
} ||
die "Could not include .pdb files"

printf "%s\n%s\n%s\n%s%s" \
etc_gitconfig_dir="${etc_gitconfig%/gitconfig}"
printf "%s\n%s\n%s\n%s\n%s%s" \
"#define APP_VERSION '$displayver'" \
"#define FILENAME_VERSION '$version'" \
"#define BITNESS '$BITNESS'" \
"#define SOURCE_DIR '$(cygpath -aw /)'" \
"#define ETC_GITCONFIG_DIR '${etc_gitconfig_dir//\//\\}'" \
"$inno_defines" \
>config.iss

Expand Down
10 changes: 8 additions & 2 deletions make-file-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,16 @@ pacman -Q filesystem $SH_FOR_REBASE rebase \
mingw-w64-$ARCH-xpdf-tools) \
>>"$PACKAGE_VERSIONS_FILE"

test -n "$ETC_GITCONFIG" ||
ETC_GITCONFIG=etc/gitconfig

test -n "$ETC_GITATTRIBUTES" ||
ETC_GITATTRIBUTES="${ETC_GITCONFIG%/*}/gitattributes"

cat <<EOF
etc/fstab
etc/nsswitch.conf
mingw$BITNESS/etc/gitconfig
$ETC_GITATTRIBUTES
usr/bin/rebase.exe
usr/bin/rebaseall
EOF
Expand All @@ -272,10 +278,10 @@ etc/bash.bashrc
etc/msystem
usr/bin/dash.exe
usr/bin/getopt.exe
mingw$BITNESS/etc/gitattributes
EOF

test -n "$MINIMAL_GIT" || cat <<EOF
$ETC_GITCONFIG
etc/post-install/01-devices.post
etc/post-install/03-mtab.post
etc/post-install/06-windows-files.post
Expand Down
17 changes: 16 additions & 1 deletion mingit/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ case "$SCRIPT_PATH" in
;;
esac

etc_gitconfig="$(git -c core.editor=echo config --system -e 2>/dev/null)" &&
etc_gitconfig="$(cygpath -au "$etc_gitconfig")" &&
etc_gitconfig="${etc_gitconfig#/}" ||
die "Could not determine the path of the system config"

rm -rf "$SCRIPT_PATH"/root &&
mkdir -p "$SCRIPT_PATH"/root ||
die "Could not create overlay directory"
Expand All @@ -64,6 +69,16 @@ die "Could not copy license file"
mkdir -p "$SCRIPT_PATH"/root/etc ||
die "Could not make etc/"

cat >"$SCRIPT_PATH"/root/"$etc_gitconfig" <<EOF ||
[include]
; include Git for Windows' system config in order
; to inherit settings like `core.autocrlf`
path = C:\Program Files (x86)\Git\etc\gitconfig
path = C:\Program Files\Git\etc\gitconfig
$(cat "/$etc_gitconfig")
EOF
die "Could not generate system config"

test -z "$include_pdbs" || {
find "$SCRIPT_PATH/root" -name \*.pdb -exec rm {} \; &&
"$SCRIPT_PATH"/../please.sh bundle-pdbs \
Expand All @@ -72,7 +87,7 @@ test -z "$include_pdbs" || {
die "Could not unpack .pdb files"

# Make a list of files to include
LIST="$(ARCH=$ARCH BITNESS=$BITNESS MINIMAL_GIT=1 \
LIST="$(ARCH=$ARCH BITNESS=$BITNESS MINIMAL_GIT=1 ETC_GITCONFIG="$etc_gitconfig" \
PACKAGE_VERSIONS_FILE="$SCRIPT_PATH"/root/etc/package-versions.txt \
sh "$SCRIPT_PATH"/../make-file-list.sh "$@")" ||
die "Could not generate file list"
Expand Down
Loading