Skip to content

Commit

Permalink
rebase --no-verify
Browse files Browse the repository at this point in the history
It is sometimes desirable to disable the safety net of pre-rebase hook
when the user knows what he is doing (for example, when the original
changes on the branch have not been shown to the public yet).

This teaches --no-verify option to git-rebase, which is similar to the way
pre-commit hook is bypassed by git-commit.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Nanako Shiraishi authored and spearce committed Oct 6, 2008
1 parent 276328f commit c442765
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
10 changes: 9 additions & 1 deletion git-rebase--interactive.sh
Expand Up @@ -26,6 +26,7 @@ i,interactive always used (no-op)
continue continue rebasing process
abort abort rebasing process and restore original branch
skip skip current patch and continue rebasing process
no-verify override pre-rebase hook from stopping the operation
"

. git-sh-setup
Expand All @@ -41,6 +42,7 @@ PRESERVE_MERGES=
STRATEGY=
ONTO=
VERBOSE=
OK_TO_SKIP_PRE_REBASE=

GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
mark the corrected paths with 'git add <paths>', and
Expand All @@ -66,7 +68,8 @@ output () {
}

run_pre_rebase_hook () {
if test -x "$GIT_DIR/hooks/pre-rebase"
if test -z "$OK_TO_SKIP_PRE_REBASE" &&
test -x "$GIT_DIR/hooks/pre-rebase"
then
"$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
echo >&2 "The pre-rebase hook refused to rebase."
Expand Down Expand Up @@ -416,6 +419,11 @@ get_saved_options () {
while test $# != 0
do
case "$1" in
--no-verify)
OK_TO_SKIP_PRE_REBASE=yes
;;
--verify)
;;
--continue)
is_standalone "$@" || usage
get_saved_options
Expand Down
7 changes: 6 additions & 1 deletion git-rebase.sh
Expand Up @@ -34,6 +34,7 @@ set_reflog_action rebase
require_work_tree
cd_to_toplevel

OK_TO_SKIP_PRE_REBASE=
RESOLVEMSG="
When you have resolved this problem run \"git rebase --continue\".
If you would prefer to skip this patch, instead run \"git rebase --skip\".
Expand Down Expand Up @@ -145,7 +146,8 @@ is_interactive () {
}

run_pre_rebase_hook () {
if test -x "$GIT_DIR/hooks/pre-rebase"
if test -z "$OK_TO_SKIP_PRE_REBASE" &&
test -x "$GIT_DIR/hooks/pre-rebase"
then
"$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
echo >&2 "The pre-rebase hook refused to rebase."
Expand All @@ -170,6 +172,9 @@ fi
while test $# != 0
do
case "$1" in
--no-verify)
OK_TO_SKIP_PRE_REBASE=yes
;;
--continue)
test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
die "No rebase in progress?"
Expand Down
16 changes: 16 additions & 0 deletions t/t3409-rebase-hook.sh
Expand Up @@ -123,4 +123,20 @@ test_expect_success 'pre-rebase hook stops rebase (2)' '
test 0 = $(git rev-list HEAD...side | wc -l)
'

test_expect_success 'rebase --no-verify overrides pre-rebase (1)' '
git checkout test &&
git reset --hard side &&
git rebase --no-verify master &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test "z$(cat git)" = zworld
'

test_expect_success 'rebase --no-verify overrides pre-rebase (2)' '
git checkout test &&
git reset --hard side &&
EDITOR=true git rebase --no-verify -i master &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test "z$(cat git)" = zworld
'

test_done

0 comments on commit c442765

Please sign in to comment.