From 46a3003a2f48f9feb595c318446402af35021b83 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 25 Aug 2016 11:40:18 +0100 Subject: [PATCH] update.sh: reset pre-stash, die if stash fails. A `git reset --hard` without stashing first risks nuking in-progress work. A `git reset --mixed` should allow stashing to occur more often on e.g. merge conflicts. Fixes #766. --- Library/Homebrew/cmd/update.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 7b57bde246..b052631fe5 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -226,9 +226,18 @@ merge_or_rebase() { fi git merge --abort &>/dev/null git rebase --abort &>/dev/null - git -c "user.email=brew-update@localhost" \ - -c "user.name=brew update" \ - stash save --include-untracked "${QUIET_ARGS[@]}" + git reset --mixed "${QUIET_ARGS[@]}" + if ! git -c "user.email=brew-update@localhost" \ + -c "user.name=brew update" \ + stash save --include-untracked "${QUIET_ARGS[@]}" + then + odie <