update-bash: improve reset_on_interrupt
* make sure exit after reset. * more wide guardian range. We should trap reset_on_interrupt as soon as we are about to change any files. * check INITIAL_BRANCH against UPSTREAM_BRANCH
This commit is contained in:
parent
fafe8f0f53
commit
2d84fc56fe
@ -121,14 +121,24 @@ pop_stash_message() {
|
||||
# Don't warn about QUIET_ARGS; they need to be unquoted.
|
||||
# shellcheck disable=SC2086
|
||||
reset_on_interrupt() {
|
||||
[[ -z "$INITIAL_BRANCH" ]] || git checkout "$INITIAL_BRANCH"
|
||||
git reset --hard "$INITIAL_REVISION" $QUIET_ARGS
|
||||
if [[ -n "$INITIAL_BRANCH" ]]
|
||||
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
||||
then
|
||||
git checkout "$INITIAL_BRANCH"
|
||||
fi
|
||||
|
||||
if [[ -n "$INITIAL_REVISION" ]]
|
||||
then
|
||||
git reset --hard "$INITIAL_REVISION" $QUIET_ARGS
|
||||
fi
|
||||
|
||||
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
||||
then
|
||||
pop_stash
|
||||
else
|
||||
pop_stash_message
|
||||
fi
|
||||
|
||||
exit 130
|
||||
}
|
||||
|
||||
# Don't warn about QUIET_ARGS; they need to be unquoted.
|
||||
@ -145,6 +155,8 @@ pull() {
|
||||
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
|
||||
UPSTREAM_BRANCH="$(upstream_branch)"
|
||||
|
||||
trap reset_on_interrupt SIGINT
|
||||
|
||||
if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]]
|
||||
then
|
||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
||||
@ -191,8 +203,6 @@ pull() {
|
||||
# ensure we don't munge line endings on checkout
|
||||
git config core.autocrlf false
|
||||
|
||||
trap reset_on_interrupt SIGINT
|
||||
|
||||
if [[ -n "$HOMEBREW_REBASE" ]]
|
||||
then
|
||||
git rebase $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
|
||||
@ -200,11 +210,11 @@ pull() {
|
||||
git merge --no-edit --ff $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
|
||||
fi
|
||||
|
||||
trap - SIGINT
|
||||
|
||||
CURRENT_REVISION="$(read_current_revision)"
|
||||
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$(git rev-parse "$UPSTREAM_BRANCH")"
|
||||
|
||||
trap '' SIGINT
|
||||
|
||||
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
||||
then
|
||||
git checkout "$INITIAL_BRANCH" $QUIET_ARGS
|
||||
@ -212,6 +222,8 @@ pull() {
|
||||
else
|
||||
pop_stash_message
|
||||
fi
|
||||
|
||||
trap - SIGINT
|
||||
}
|
||||
|
||||
update-bash() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user