Teach rebase -i to honor pre-rebase hook

The original git-rebase honored pre-rebase hook so that public branches
can be protected from getting rebased, but rebase --interactive ignored
the hook entirely.  This fixes it.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Nanako Shiraishi
2008-10-06 14:14:24 +09:00
committed by Shawn O. Pearce
parent 00e5d48a9a
commit d70b4a8f4b
3 changed files with 148 additions and 7 deletions

View File

@ -65,6 +65,16 @@ output () {
esac
}
run_pre_rebase_hook () {
if test -x "$GIT_DIR/hooks/pre-rebase"
then
"$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
echo >&2 "The pre-rebase hook refused to rebase."
exit 1
}
fi
}
require_clean_work_tree () {
# test if working tree is dirty
git rev-parse --verify HEAD > /dev/null &&
@ -507,6 +517,7 @@ first and then run 'git rebase --continue' again."
;;
--)
shift
run_pre_rebase_hook ${1+"$@"}
test $# -eq 1 -o $# -eq 2 || usage
test -d "$DOTEST" &&
die "Interactive rebase already started"