From f9e8531924138472a4fcf6ec9ff3f65f72286588 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 20 Jul 2022 18:18:12 +0800 Subject: [PATCH 1/3] cmd/update: stop Git's fsmonitor when needed Git's fsmonitor daemon will prevent our update lock file from being released if it is running before a `brew update`. Let's fix that by stopping it whenever necessary so our update lock is released upon completion. Fixes #13521. --- Library/Homebrew/cmd/update.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 0269d73edb..1aed9905cd 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -556,6 +556,12 @@ EOS [[ -d "${DIR}/.git" ]] || continue cd "${DIR}" || continue + # Git's fsmonitor daemon will not release our lock unless we stop it. + if git fsmonitor--daemon status &>/dev/null + then + git fsmonitor--daemon stop 2>/dev/null + fi + if ! git config --local --get remote.origin.url &>/dev/null then opoo "No remote 'origin' in ${DIR}, skipping update!" From c42169249e6dce5eb39239eb314873977ba9e57b Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 28 Jul 2022 22:02:31 +0800 Subject: [PATCH 2/3] cmd/update: stop fsmonitor after all Git operations complete Also, skip the status check, as that doesn't really help us. --- Library/Homebrew/cmd/update.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 1aed9905cd..7b9b2ad729 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -556,12 +556,6 @@ EOS [[ -d "${DIR}/.git" ]] || continue cd "${DIR}" || continue - # Git's fsmonitor daemon will not release our lock unless we stop it. - if git fsmonitor--daemon status &>/dev/null - then - git fsmonitor--daemon stop 2>/dev/null - fi - if ! git config --local --get remote.origin.url &>/dev/null then opoo "No remote 'origin' in ${DIR}, skipping update!" @@ -746,6 +740,9 @@ EOS merge_or_rebase "${DIR}" "${TAP_VAR}" "${UPSTREAM_BRANCH}" [[ -n "${HOMEBREW_VERBOSE}" ]] && echo fi + + # Git's fsmonitor daemon will not release our lock unless we stop it. + git fsmonitor--daemon stop 2>/dev/null done if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] From 5e60d54e709642014c8fcd1d8e30215165ce582d Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 28 Jul 2022 22:20:07 +0800 Subject: [PATCH 3/3] update: disable Git fsmonitor for all Homebrew repositories Stopping the fsmonitor doesn't seem to work, so let's just prevent the fsmonitor from watching our repositories. --- Library/Homebrew/cmd/update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 7b9b2ad729..c358e439a3 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -556,6 +556,9 @@ EOS [[ -d "${DIR}/.git" ]] || continue cd "${DIR}" || continue + # Git's fsmonitor prevents the release of our locks + git config --bool core.fsmonitor false + if ! git config --local --get remote.origin.url &>/dev/null then opoo "No remote 'origin' in ${DIR}, skipping update!" @@ -740,9 +743,6 @@ EOS merge_or_rebase "${DIR}" "${TAP_VAR}" "${UPSTREAM_BRANCH}" [[ -n "${HOMEBREW_VERBOSE}" ]] && echo fi - - # Git's fsmonitor daemon will not release our lock unless we stop it. - git fsmonitor--daemon stop 2>/dev/null done if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]]