diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index b3248c5cb..09e68f688 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -86,11 +86,19 @@ class Updater # the refspec ensures that 'origin/master' gets updated args << "refs/heads/master:refs/remotes/origin/master" - safe_system "git", *args + reset_on_interrupt { safe_system "git", *args } @current_revision = read_current_revision end + def reset_on_interrupt + ignore_interrupts { yield } + ensure + if $?.signaled? && $?.termsig == 2 # SIGINT + safe_system "git", "reset", "--hard", @initial_revision + end + end + # Matches raw git diff format (see `man git-diff-tree`) DIFFTREE_RX = /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} [0-9a-fA-F]{40} ([ACDMR])\d{0,3}\t(.+?)(?:\t(.+))?$/ |
