update: restore previous state when interrupted
Fixes Homebrew/homebrew#19460. Closes Homebrew/homebrew#22375.
This commit is contained in:
parent
15a3ae3d28
commit
4c55082e7c
@ -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(.+))?$/
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user