rebase --no-verify
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>
Nanako Shiraishi committed
Oct 6, 2008 at 14:14 UTC
c44276563f96bba7133e3ee4144b7e0364d499b9
3 files changed
+31
-2
git-rebase--interactive.sh
+9
-1
@@ -26,6 +26,7 @@ i,interactive always used (no-op)
26
continue continue rebasing process
27
abort abort rebasing process and restore original branch
28
skip skip current patch and continue rebasing process
29
+no-verify override pre-rebase hook from stopping the operation
30
"
31
32
. git-sh-setup
@@ -41,6 +42,7 @@ PRESERVE_MERGES=
42
STRATEGY=
43
ONTO=
44
VERBOSE=
45
+OK_TO_SKIP_PRE_REBASE=
46
47
GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
48
mark the corrected paths with 'git add <paths>', and
@@ -66,7 +68,8 @@ output () {
68
}
69
70
run_pre_rebase_hook () {
69
- if test -x "$GIT_DIR/hooks/pre-rebase"
71
+ if test -z "$OK_TO_SKIP_PRE_REBASE" &&
72
+ test -x "$GIT_DIR/hooks/pre-rebase"
73
then
74
"$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
75
echo >&2 "The pre-rebase hook refused to rebase."
@@ -416,6 +419,11 @@ get_saved_options () {
419
while test $# != 0
420
do
421
case "$1" in
422
+ --no-verify)
423
+ OK_TO_SKIP_PRE_REBASE=yes
424
+ ;;
425
+ --verify)
426
+ ;;
427
--continue)
428
is_standalone "$@" || usage
429
get_saved_options
git-rebase.sh
+6
-1
@@ -34,6 +34,7 @@ set_reflog_action rebase
34
require_work_tree
35
cd_to_toplevel
36
37
+OK_TO_SKIP_PRE_REBASE=
38
RESOLVEMSG="
39
When you have resolved this problem run \"git rebase --continue\".
40
If you would prefer to skip this patch, instead run \"git rebase --skip\".
@@ -145,7 +146,8 @@ is_interactive () {
146
}
147
148
run_pre_rebase_hook () {
148
- if test -x "$GIT_DIR/hooks/pre-rebase"
149
+ if test -z "$OK_TO_SKIP_PRE_REBASE" &&
150
+ test -x "$GIT_DIR/hooks/pre-rebase"
151
then
152
"$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
153
echo >&2 "The pre-rebase hook refused to rebase."
@@ -170,6 +172,9 @@ fi
172
while test $# != 0
173
do
174
case "$1" in
175
+ --no-verify)
176
+ OK_TO_SKIP_PRE_REBASE=yes
177
+ ;;
178
--continue)
179
test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
180
die "No rebase in progress?"
t/t3409-rebase-hook.sh
+16
@@ -123,4 +123,20 @@ test_expect_success 'pre-rebase hook stops rebase (2)' '
123
test 0 = $(git rev-list HEAD...side | wc -l)
124
'
125
126
+test_expect_success 'rebase --no-verify overrides pre-rebase (1)' '
127
+ git checkout test &&
128
+ git reset --hard side &&
129
+ git rebase --no-verify master &&
130
+ test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
131
+ test "z$(cat git)" = zworld
132
+'
133
+
134
+test_expect_success 'rebase --no-verify overrides pre-rebase (2)' '
135
+ git checkout test &&
136
+ git reset --hard side &&
137
+ EDITOR=true git rebase --no-verify -i master &&
138
+ test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
139
+ test "z$(cat git)" = zworld
140
+'
141
+
142
test_done