From 2eaca985057a01aa91047151019737daa65d05e5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 22 Apr 2021 20:46:51 +0200 Subject: [PATCH] =?UTF-8?q?Avoid=20=E2=80=9CFailure=20while=20executing;?= =?UTF-8?q?=20`git=20config=20--replace-all=20homebrew.devcmdrun=20true`?= =?UTF-8?q?=20exited=20with=20255.=E2=80=9D=20error.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/settings.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/settings.rb b/Library/Homebrew/settings.rb index ea583d2c19..8a58e94199 100644 --- a/Library/Homebrew/settings.rb +++ b/Library/Homebrew/settings.rb @@ -17,28 +17,27 @@ module Homebrew def read(setting, repo: HOMEBREW_REPOSITORY) return unless (repo/".git/config").exist? - repo.cd do - Utils.popen_read("git", "config", "--get", "homebrew.#{setting}").chomp.presence - end + system_command("git", args: ["config", "--get", "homebrew.#{setting}"], chdir: repo).stdout.chomp.presence end sig { params(setting: T.any(String, Symbol), value: T.any(String, T::Boolean), repo: Pathname).void } def write(setting, value, repo: HOMEBREW_REPOSITORY) return unless (repo/".git/config").exist? - repo.cd do - system_command! "git", args: ["config", "--replace-all", "homebrew.#{setting}", value.to_s] - end + value = value.to_s + + return if read(setting, repo: repo) == value + + system_command! "git", args: ["config", "--replace-all", "homebrew.#{setting}", value], chdir: repo end sig { params(setting: T.any(String, Symbol), repo: Pathname).void } def delete(setting, repo: HOMEBREW_REPOSITORY) return unless (repo/".git/config").exist? + return if read(setting, repo: repo).blank? - repo.cd do - system_command! "git", args: ["config", "--unset-all", "homebrew.#{setting}"] - end + system_command! "git", args: ["config", "--unset-all", "homebrew.#{setting}"], chdir: repo end end end