From 5155c9073bb33bef1e0a20a44274d1744ad686d7 Mon Sep 17 00:00:00 2001 From: Adrian Ho Date: Sat, 8 Oct 2022 21:57:44 +0800 Subject: [PATCH] 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 --- Library/Homebrew/cmd/update-reset.sh | 2 ++ Library/Homebrew/cmd/update.sh | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/update-reset.sh b/Library/Homebrew/cmd/update-reset.sh index bfd1234e5e..d701da7c41 100644 --- a/Library/Homebrew/cmd/update-reset.sh +++ b/Library/Homebrew/cmd/update-reset.sh @@ -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 diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 83fe382987..2f75802821 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -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