Skip to content

Commit 8f9bfb6

Browse files
Martin von Zweigbergkgitster
authored andcommitted
rebase: reorder validation steps
Reorder validation steps in preparation for the validation to be factored out from git-rebase--interactive.sh into git-rebase.sh. The main functional difference is that the pre-rebase hook will no longer be run if the work tree is dirty. Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f3889b8 commit 8f9bfb6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

git-rebase--interactive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,12 @@ else
792792
test -z "$onto" &&
793793
die "You must specify --onto when using --root"
794794
fi
795+
require_clean_work_tree "rebase" "Please commit or stash them."
796+
795797
run_pre_rebase_hook "$upstream_arg" "$@"
796798

797799
comment_for_reflog start
798800

799-
require_clean_work_tree "rebase" "Please commit or stash them."
800-
801801
if test ! -z "$1"
802802
then
803803
output git checkout "$1" -- ||

git-rebase.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,6 @@ fi
433433

434434
test "$type" = interactive && run_interactive_rebase "$@"
435435

436-
require_clean_work_tree "rebase" "Please commit or stash them."
437-
438436
if test -z "$rebase_root"
439437
then
440438
# The upstream head must be given. Make sure it is valid.
@@ -476,9 +474,6 @@ case "$onto_name" in
476474
;;
477475
esac
478476

479-
# If a hook exists, give it a chance to interrupt
480-
run_pre_rebase_hook "$upstream_arg" "$@"
481-
482477
# If the branch to rebase is given, that is the branch we will rebase
483478
# $branch_name -- branch being rebased, or HEAD (already detached)
484479
# $orig_head -- commit object name of tip of the branch before rebasing
@@ -517,6 +512,8 @@ case "$#" in
517512
esac
518513
orig_head=$branch
519514

515+
require_clean_work_tree "rebase" "Please commit or stash them."
516+
520517
# Now we are rebasing commits $upstream..$branch (or with --root,
521518
# everything leading up to $branch) on top of $onto
522519

@@ -538,6 +535,9 @@ then
538535
fi
539536
fi
540537

538+
# If a hook exists, give it a chance to interrupt
539+
run_pre_rebase_hook "$upstream_arg" "$@"
540+
541541
# Detach HEAD and reset the tree
542542
say "First, rewinding head to replay your work on top of it..."
543543
git checkout -q "$onto^0" || die "could not detach HEAD"

0 commit comments

Comments
 (0)