From 9789726fff9497855080026b6e1c2d07af5f6284 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Sat, 12 Dec 2015 17:03:39 +0100 Subject: [PATCH] update: make stashing local changes more robust Users with local changes and without a configured Git identity won't be able to update Homebrew via `brew update`, as the update will fail when trying to stash the local modifications with `git stash`. They will be unable to proceed until they follow Git's advice to configure their identity or they manage to revert their local changes. This change always sets a commit e-mail and name, avoiding this issue. A nice bonus is that experienced Git users can see who created the stash commit (identifying `brew update` as the author). Fixes Homebrew/homebrew#46930. Closes Homebrew/homebrew#46939. Signed-off-by: Martin Afanasjew --- Library/Homebrew/cmd/update.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index dfabe95eec..08062e15b5 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -225,7 +225,9 @@ class Updater puts "Stashing uncommitted changes to #{repository}." system "git", "status", "--short", "--untracked-files=all" end - safe_system "git", "stash", "save", "--include-untracked", *@quiet_args + safe_system "git", "-c", "user.email=brew-update@localhost", + "-c", "user.name=brew update", + "stash", "save", "--include-untracked", *@quiet_args safe_system "git", "reset", "--hard", *@quiet_args @stashed = true end