Skip to content

Commit 45e2acf

Browse files
Martin von Zweigbergkgitster
authored andcommitted
rebase: define options in OPTIONS_SPEC
Interactive rebase used to have its own command line processing. Since it used the 'git rev-parse --parseopt' functionality exposed through git-sh-setup, it had some flexibility, like matching prefixes of long options, that non-interactive rebase didn't. When interactive rebase's command line processing was factored out into git-rebase.sh in cf432ca (rebase: factor out command line option processing, 2011-02-06), this flexibility was lost. Give back that flexibility to interactive and non-interactive by defining its options in OPTIONS_SPEC. Also improve the usage message to contain the --continue, --skip and --abort sub commands. Reported-by: Johannes Sixt <[email protected]> Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fdb76c1 commit 45e2acf

File tree

1 file changed

+56
-45
lines changed

1 file changed

+56
-45
lines changed

git-rebase.sh

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,39 @@ Example: git-rebase master~1 topic
2828
'
2929

3030
SUBDIRECTORY_OK=Yes
31-
OPTIONS_SPEC=
31+
OPTIONS_KEEPDASHDASH=
32+
OPTIONS_SPEC="\
33+
git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]
34+
git rebase [-i] [options] --onto <newbase> --root [<branch>]
35+
git-rebase [-i] --continue | --abort | --skip
36+
--
37+
Available options are
38+
v,verbose! display a diffstat of what changed upstream
39+
q,quiet! be quiet. implies --no-stat
40+
onto=! rebase onto given branch instead of upstream
41+
p,preserve-merges! try to recreate merges instead of ignoring them
42+
s,strategy=! use the given merge strategy
43+
no-ff! cherry-pick all commits, even if unchanged
44+
m,merge! use merging strategies to rebase
45+
i,interactive! let the user edit the list of commits to rebase
46+
f,force-rebase! force rebase even if branch is up to date
47+
X,strategy-option=! pass the argument through to the merge strategy
48+
stat! display a diffstat of what changed upstream
49+
n,no-stat! do not show diffstat of what changed upstream
50+
verify allow pre-rebase hook to run
51+
rerere-autoupdate allow rerere to update index with resolved conflicts
52+
root! rebase all reachable commits up to the root(s)
53+
autosquash move commits that begin with squash!/fixup! under -i
54+
committer-date-is-author-date! passed to 'git am'
55+
ignore-date! passed to 'git am'
56+
whitespace=! passed to 'git apply'
57+
ignore-whitespace! passed to 'git apply'
58+
C=! passed to 'git apply'
59+
Actions:
60+
continue! continue rebasing process
61+
abort! abort rebasing process and restore original branch
62+
skip! skip current patch and continue rebasing process
63+
"
3264
. git-sh-setup
3365
set_reflog_action rebase
3466
require_work_tree
@@ -175,18 +207,18 @@ do
175207
ok_to_skip_pre_rebase=
176208
;;
177209
--continue|--skip|--abort)
178-
test $total_argc -eq 1 || usage
210+
test $total_argc -eq 2 || usage
179211
action=${1##--}
180212
;;
181213
--onto)
182214
test 2 -le "$#" || usage
183215
onto="$2"
184216
shift
185217
;;
186-
-i|--interactive)
218+
-i)
187219
interactive_rebase=explicit
188220
;;
189-
-p|--preserve-merges)
221+
-p)
190222
preserve_merges=t
191223
test -z "$interactive_rebase" && interactive_rebase=implied
192224
;;
@@ -196,62 +228,42 @@ do
196228
--no-autosquash)
197229
autosquash=
198230
;;
199-
-M|-m|--m|--me|--mer|--merg|--merge)
231+
-M|-m)
200232
do_merge=t
201233
;;
202-
-X*|--strategy-option*)
203-
case "$#,$1" in
204-
1,-X|1,--strategy-option)
205-
usage ;;
206-
*,-X|*,--strategy-option)
207-
newopt="$2"
208-
shift ;;
209-
*,--strategy-option=*)
210-
newopt="$(expr " $1" : ' --strategy-option=\(.*\)')" ;;
211-
*,-X*)
212-
newopt="$(expr " $1" : ' -X\(.*\)')" ;;
213-
1,*)
214-
usage ;;
215-
esac
216-
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
234+
-X)
235+
shift
236+
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$1")"
217237
do_merge=t
218238
test -z "$strategy" && strategy=recursive
219239
;;
220-
-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
221-
--strateg=*|--strategy=*|\
222-
-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
223-
case "$#,$1" in
224-
*,*=*)
225-
strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;;
226-
1,*)
227-
usage ;;
228-
*)
229-
strategy="$2"
230-
shift ;;
231-
esac
240+
-s)
241+
shift
242+
strategy="$1"
232243
do_merge=t
233244
;;
234-
-n|--no-stat)
245+
-n)
235246
diffstat=
236247
;;
237248
--stat)
238249
diffstat=t
239250
;;
240-
-v|--verbose)
251+
-v)
241252
verbose=t
242253
diffstat=t
243254
GIT_QUIET=
244255
;;
245-
-q|--quiet)
256+
-q)
246257
GIT_QUIET=t
247258
git_am_opt="$git_am_opt -q"
248259
verbose=
249260
diffstat=
250261
;;
251-
--whitespace=*)
252-
git_am_opt="$git_am_opt $1"
262+
--whitespace)
263+
shift
264+
git_am_opt="$git_am_opt --whitespace=$1"
253265
case "$1" in
254-
--whitespace=fix|--whitespace=strip)
266+
fix|strip)
255267
force_rebase=t
256268
;;
257269
esac
@@ -263,22 +275,21 @@ do
263275
git_am_opt="$git_am_opt $1"
264276
force_rebase=t
265277
;;
266-
-C*)
267-
git_am_opt="$git_am_opt $1"
278+
-C)
279+
shift
280+
git_am_opt="$git_am_opt -C$1"
268281
;;
269282
--root)
270283
rebase_root=t
271284
;;
272-
-f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)
285+
-f|--no-ff)
273286
force_rebase=t
274287
;;
275288
--rerere-autoupdate|--no-rerere-autoupdate)
276289
allow_rerere_autoupdate="$1"
277290
;;
278-
-*)
279-
usage
280-
;;
281-
*)
291+
--)
292+
shift
282293
break
283294
;;
284295
esac

0 commit comments

Comments
 (0)