summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-02-13 07:17:04 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-02-13 08:17:33 (GMT)
commit9a111c91b01455ee1ea9f33c60da7ad50d460a7b (patch)
tree4559d164c9643ff2dd2bded5ebafe196c98fbe35 /git-rebase.sh
parentbd9ca0baff88107e26915cdaaf9821dc70a187e3 (diff)
downloadgit-9a111c91b01455ee1ea9f33c60da7ad50d460a7b.zip
git-9a111c91b01455ee1ea9f33c60da7ad50d460a7b.tar.gz
git-9a111c91b01455ee1ea9f33c60da7ad50d460a7b.tar.bz2
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>
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 16d4359..f84160d 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -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)