summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorNanako Shiraishi <nanako3@lavabit.com>2008-10-06 14:14:24 +0900
committerShawn O. Pearce <spearce@spearce.org>2008-10-06 01:19:14 -0700
commitd70b4a8f4ba79fb83dc95e9483f9fb3feaf578b7 (patch)
tree56208dadfbdd238a76b6a7c254900ef7fc9a0f86 /git-rebase.sh
parent00e5d48a9aef3228496d6f517a272fa095c562fe (diff)
downloadgit-d70b4a8f4ba79fb83dc95e9483f9fb3feaf578b7.tar.gz
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>
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index 528b604cd5..a30d40c005 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -144,6 +144,16 @@ is_interactive () {
done && test -n "$1"
}
+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
+}
+
test -f "$GIT_DIR"/rebase-apply/applying &&
die 'It looks like git-am is in progress. Cannot rebase.'
@@ -320,13 +330,7 @@ onto_name=${newbase-"$upstream_name"}
onto=$(git rev-parse --verify "${onto_name}^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
+run_pre_rebase_hook ${1+"$@"}
# If the branch to rebase is given, that is the branch we will rebase
# $branch_name -- branch being rebased, or HEAD (already detached)