diff --git a/.gitignore b/.gitignore index 9f6ee53e4a..56bb310695 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/ReleaseNotes.md b/ReleaseNotes.md index e57dd16ca7..7d8f7f0e72 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -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). @@ -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) diff --git a/git-extra/git-extra.install.in b/git-extra/git-extra.install.in index de7041cc58..b2c195c84a 100644 --- a/git-extra/git-extra.install.in +++ b/git-extra/git-extra.install.in @@ -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 && diff --git a/installer/install.iss b/installer/install.iss index 68cba61903..a6a9e7a8a3 100644 --- a/installer/install.iss +++ b/installer/install.iss @@ -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 @@ -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; @@ -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 @@ -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; { @@ -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 @@ -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 diff --git a/installer/release.sh b/installer/release.sh index b882ca5a31..bb29146ddd 100755 --- a/installer/release.sh +++ b/installer/release.sh @@ -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 @@ -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)" || @@ -156,11 +162,9 @@ 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 @@ -168,21 +172,18 @@ test -z "$GITCONFIG_PATH" || { 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" @@ -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' \ @@ -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 diff --git a/make-file-list.sh b/make-file-list.sh index 5c7f201ec7..0ca00ddad4 100755 --- a/make-file-list.sh +++ b/make-file-list.sh @@ -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 <"$SCRIPT_PATH"/root/"$etc_gitconfig" <