rebase: factor out call to pre-rebase hook
Remove the call to the pre-rebase hook from git-rebase--interactive.sh and rely on the call in git-rebase.sh. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin von Zweigbergk committed
Feb 6, 2011 at 13:43 UTC
cc1453e1dadc750a2d5c68b0e053b2221d212ef6
2 files changed
+7
-19
git-rebase--interactive.sh
-14
@@ -109,18 +109,6 @@ commit_message () {
109
git cat-file commit "$1" | sed "1,/^$/d"
110
}
111
112
-run_pre_rebase_hook () {
113
- if test -z "$ok_to_skip_pre_rebase" &&
114
- test -x "$GIT_DIR/hooks/pre-rebase"
115
- then
116
- "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
117
- echo >&2 "The pre-rebase hook refused to rebase."
118
- exit 1
119
- }
120
- fi
121
-}
122
-
123
-
112
orig_reflog_action="$GIT_REFLOG_ACTION"
113
114
comment_for_reflog () {
@@ -753,8 +741,6 @@ esac
741
git var GIT_COMMITTER_IDENT >/dev/null ||
742
die "You need to set your committer info first"
743
756
-run_pre_rebase_hook "$upstream_arg" "$@"
757
-
744
comment_for_reflog start
745
746
if test ! -z "$switch_to"
git-rebase.sh
+7
-5
@@ -184,7 +184,7 @@ run_interactive_rebase () {
184
GIT_EDITOR=:
185
export GIT_EDITOR
186
fi
187
- . git-rebase--interactive "$@"
187
+ . git-rebase--interactive
188
}
189
190
run_pre_rebase_hook () {
@@ -513,15 +513,15 @@ orig_head=$branch
513
514
require_clean_work_tree "rebase" "Please commit or stash them."
515
516
-test "$type" = interactive && run_interactive_rebase "$@"
517
-
516
# Now we are rebasing commits $upstream..$branch (or with --root,
517
# everything leading up to $branch) on top of $onto
518
519
# Check if we are already based on $onto with linear history,
522
-# but this should be done only when upstream and onto are the same.
520
+# but this should be done only when upstream and onto are the same
521
+# and if this is not an interactive rebase.
522
mb=$(git merge-base "$onto" "$branch")
524
-if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
523
+if test "$type" != interactive && test "$upstream" = "$onto" &&
524
+ test "$mb" = "$onto" &&
525
# linear history?
526
! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null
527
then
@@ -539,6 +539,8 @@ fi
539
# If a hook exists, give it a chance to interrupt
540
run_pre_rebase_hook "$upstream_arg" "$@"
541
542
+test "$type" = interactive && run_interactive_rebase
543
+
544
# Detach HEAD and reset the tree
545
say "First, rewinding head to replay your work on top of it..."
546
git checkout -q "$onto^0" || die "could not detach HEAD"