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.
|
# Don't warn about QUIET_ARGS; they need to be unquoted.
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
reset_on_interrupt() {
|
reset_on_interrupt() {
|
||||||
[[ -z "$INITIAL_BRANCH" ]] || git checkout "$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
|
git reset --hard "$INITIAL_REVISION" $QUIET_ARGS
|
||||||
if [[ -n "$INITIAL_BRANCH" ]]
|
fi
|
||||||
|
|
||||||
|
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
||||||
then
|
then
|
||||||
pop_stash
|
pop_stash
|
||||||
else
|
else
|
||||||
pop_stash_message
|
pop_stash_message
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exit 130
|
||||||
}
|
}
|
||||||
|
|
||||||
# Don't warn about QUIET_ARGS; they need to be unquoted.
|
# 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)"
|
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
|
||||||
UPSTREAM_BRANCH="$(upstream_branch)"
|
UPSTREAM_BRANCH="$(upstream_branch)"
|
||||||
|
|
||||||
|
trap reset_on_interrupt SIGINT
|
||||||
|
|
||||||
if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]]
|
if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]]
|
||||||
then
|
then
|
||||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
||||||
@ -191,8 +203,6 @@ pull() {
|
|||||||
# ensure we don't munge line endings on checkout
|
# ensure we don't munge line endings on checkout
|
||||||
git config core.autocrlf false
|
git config core.autocrlf false
|
||||||
|
|
||||||
trap reset_on_interrupt SIGINT
|
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_REBASE" ]]
|
if [[ -n "$HOMEBREW_REBASE" ]]
|
||||||
then
|
then
|
||||||
git rebase $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
|
git rebase $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
|
||||||
@ -200,11 +210,11 @@ pull() {
|
|||||||
git merge --no-edit --ff $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
|
git merge --no-edit --ff $QUIET_ARGS "origin/$UPSTREAM_BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap - SIGINT
|
|
||||||
|
|
||||||
CURRENT_REVISION="$(read_current_revision)"
|
CURRENT_REVISION="$(read_current_revision)"
|
||||||
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$(git rev-parse "$UPSTREAM_BRANCH")"
|
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$(git rev-parse "$UPSTREAM_BRANCH")"
|
||||||
|
|
||||||
|
trap '' SIGINT
|
||||||
|
|
||||||
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
||||||
then
|
then
|
||||||
git checkout "$INITIAL_BRANCH" $QUIET_ARGS
|
git checkout "$INITIAL_BRANCH" $QUIET_ARGS
|
||||||
@ -212,6 +222,8 @@ pull() {
|
|||||||
else
|
else
|
||||||
pop_stash_message
|
pop_stash_message
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
trap - SIGINT
|
||||||
}
|
}
|
||||||
|
|
||||||
update-bash() {
|
update-bash() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user