diff options
| author | Jack Nagel | 2013-09-10 15:08:03 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-09-10 15:12:39 -0500 |
| commit | 4c55082e7c0bcf0c6bb2b1401286fda466ad3248 (patch) | |
| tree | 1ef248648e630f638b7477e93471fe71fcb5884a /Library | |
| parent | 15a3ae3d2836225c1eb3a05802971fc59a23a5fb (diff) | |
| download | brew-4c55082e7c0bcf0c6bb2b1401286fda466ad3248.tar.bz2 | |
update: restore previous state when interrupted
Fixes Homebrew/homebrew#19460.
Closes Homebrew/homebrew#22375.
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(.+))?$/ |
