rebase: allow a hook to refuse rebasing.
This lets a hook to interfere a rebase and help prevent certain branches from being rebased by mistake. A sample hook to show how to prevent a topic branch that has already been merged into publish branch. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
@ -36,6 +36,15 @@ other=$(git-rev-parse --verify "$1^0") || usage
|
||||
# Make sure the branch to rebase is valid.
|
||||
head=$(git-rev-parse --verify "${2-HEAD}^0") || exit
|
||||
|
||||
# If a hook exists, give it a chance to interrupt
|
||||
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
|
||||
|
||||
# If the branch to rebase is given, first switch to it.
|
||||
case "$#" in
|
||||
2)
|
||||
|
||||
Reference in New Issue
Block a user