update*: enforce sane symlinks setting

Otherwise, a global `core.symlinks = false` setting, likely in a WSL context, breaks Aliases and any other places that use symlinks.

Also enforce consistency in `git config` settings across instances.

Ref: https://github.com/Homebrew/homebrew-core/issues/112539
This commit is contained in:
Adrian Ho 2022-10-08 21:57:44 +08:00
parent fb52a12144
commit 5155c9073b
2 changed files with 8 additions and 1 deletions

View File

@ -56,6 +56,8 @@ homebrew-update-reset() {
opoo "No remote 'origin' in ${DIR}, skipping update and reset!"
continue
fi
git -C "${DIR}" config --bool core.autocrlf false
git -C "${DIR}" config --bool core.symlinks true
ohai "Fetching ${DIR}..."
git -C "${DIR}" fetch --force --tags origin
git -C "${DIR}" remote set-head origin --auto >/dev/null

View File

@ -45,6 +45,7 @@ git_init_if_necessary() {
trap '{ rm -rf .git; exit 1; }' EXIT
git init
git config --bool core.autocrlf false
git config --bool core.symlinks true
if [[ "${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}" != "${HOMEBREW_BREW_GIT_REMOTE}" ]]
then
echo "HOMEBREW_BREW_GIT_REMOTE set: using ${HOMEBREW_BREW_GIT_REMOTE} for Homebrew/brew Git remote URL."
@ -67,6 +68,7 @@ git_init_if_necessary() {
trap '{ rm -rf .git; exit 1; }' EXIT
git init
git config --bool core.autocrlf false
git config --bool core.symlinks true
if [[ "${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}" != "${HOMEBREW_CORE_GIT_REMOTE}" ]]
then
echo "HOMEBREW_CORE_GIT_REMOTE set: using ${HOMEBREW_CORE_GIT_REMOTE} for Homebrew/core Git remote URL."
@ -269,7 +271,10 @@ EOS
export HOMEBREW_UPDATE_BEFORE"${TAP_VAR}"="${INITIAL_REVISION}"
# ensure we don't munge line endings on checkout
git config core.autocrlf false
git config --bool core.autocrlf false
# make sure symlinks are saved as-is
git config --bool core.symlinks true
if [[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" && -n "${HOMEBREW_LINUXBREW_CORE_MIGRATION}" ]]
then