@matheusbsbs / matheus-bagliano / commits / 45e2acf3d3
Fork 0

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 <j6t@kdbg.org> 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 28, 2011 at 20:59 UTC 45e2acf3d33b2bc635f14af0c1d9ce698328954f
1 file changed +56 -45
git-rebase.sh
+56 -45
@@ -28,7 +28,39 @@ Example: git-rebase master~1 topic
28 '
29
30 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 +"
64 . git-sh-setup
65 set_reflog_action rebase
66 require_work_tree
@@ -175,7 +207,7 @@ do
207 ok_to_skip_pre_rebase=
208 ;;
209 --continue|--skip|--abort)
178 - test $total_argc -eq 1 || usage
210 + test $total_argc -eq 2 || usage
211 action=${1##--}
212 ;;
213 --onto)
@@ -183,10 +215,10 @@ do
215 onto="$2"
216 shift
217 ;;
186 - -i|--interactive)
218 + -i)
219 interactive_rebase=explicit
220 ;;
189 - -p|--preserve-merges)
221 + -p)
222 preserve_merges=t
223 test -z "$interactive_rebase" && interactive_rebase=implied
224 ;;
@@ -196,62 +228,42 @@ do
228 --no-autosquash)
229 autosquash=
230 ;;
199 - -M|-m|--m|--me|--mer|--merg|--merge)
231 + -M|-m)
232 do_merge=t
233 ;;
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")"
237 do_merge=t
238 test -z "$strategy" && strategy=recursive
239 ;;
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"
243 do_merge=t
244 ;;
234 - -n|--no-stat)
245 + -n)
246 diffstat=
247 ;;
248 --stat)
249 diffstat=t
250 ;;
240 - -v|--verbose)
251 + -v)
252 verbose=t
253 diffstat=t
254 GIT_QUIET=
255 ;;
245 - -q|--quiet)
256 + -q)
257 GIT_QUIET=t
258 git_am_opt="$git_am_opt -q"
259 verbose=
260 diffstat=
261 ;;
251 - --whitespace=*)
252 - git_am_opt="$git_am_opt $1"
262 + --whitespace)
263 + shift
264 + git_am_opt="$git_am_opt --whitespace=$1"
265 case "$1" in
254 - --whitespace=fix|--whitespace=strip)
266 + fix|strip)
267 force_rebase=t
268 ;;
269 esac
@@ -263,22 +275,21 @@ do
275 git_am_opt="$git_am_opt $1"
276 force_rebase=t
277 ;;
266 - -C*)
267 - git_am_opt="$git_am_opt $1"
278 + -C)
279 + shift
280 + git_am_opt="$git_am_opt -C$1"
281 ;;
282 --root)
283 rebase_root=t
284 ;;
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)
286 force_rebase=t
287 ;;
288 --rerere-autoupdate|--no-rerere-autoupdate)
289 allow_rerere_autoupdate="$1"
290 ;;
278 - -*)
279 - usage
280 - ;;
281 - *)
291 + --)
292 + shift
293 break
294 ;;
295 esac