1010# The original idea comes from Eric W. Biederman, in
1111# http://article.gmane.org/gmane.comp.version-control.git/22407
1212
13- USAGE=' (--continue | --abort | --skip | [--preserve-merges] [--verbose]
14- [--onto <branch>] <upstream> [<branch>])'
13+ OPTIONS_KEEPDASHDASH=
14+ OPTIONS_SPEC=" \
15+ git-rebase [-i] [options] [--] <upstream> [<branch>]
16+ git-rebase [-i] (--continue | --abort | --skip)
17+ --
18+ Available options are
19+ v,verbose display a diffstat of what changed upstream
20+ onto= rebase onto given branch instead of upstream
21+ p,preserve-merges try to recreate merges instead of ignoring them
22+ s,strategy= use the given merge strategy
23+ m,merge always used (no-op)
24+ i,interactive always used (no-op)
25+ Actions:
26+ continue continue rebasing process
27+ abort abort rebasing process and restore original branch
28+ skip skip current patch and continue rebasing process
29+ "
1530
16- OPTIONS_SPEC=
1731. git-sh-setup
1832require_work_tree
1933
@@ -25,10 +39,8 @@ SQUASH_MSG="$DOTEST"/message-squash
2539REWRITTEN=" $DOTEST " /rewritten
2640PRESERVE_MERGES=
2741STRATEGY=
42+ ONTO=
2843VERBOSE=
29- test -d " $REWRITTEN " && PRESERVE_MERGES=t
30- test -f " $DOTEST " /strategy && STRATEGY=" $( cat " $DOTEST " /strategy) "
31- test -f " $DOTEST " /verbose && VERBOSE=t
3244
3345GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
3446mark the corrected paths with 'git add <paths>', and
@@ -366,10 +378,27 @@ do_rest () {
366378 done
367379}
368380
381+ # check if no other options are set
382+ is_standalone () {
383+ test $# -eq 2 -a " $2 " = ' --' &&
384+ test -z " $ONTO " &&
385+ test -z " $PRESERVE_MERGES " &&
386+ test -z " $STRATEGY " &&
387+ test -z " $VERBOSE "
388+ }
389+
390+ get_saved_options () {
391+ test -d " $REWRITTEN " && PRESERVE_MERGES=t
392+ test -f " $DOTEST " /strategy && STRATEGY=" $( cat " $DOTEST " /strategy) "
393+ test -f " $DOTEST " /verbose && VERBOSE=t
394+ }
395+
369396while test $# ! = 0
370397do
371398 case " $1 " in
372399 --continue)
400+ is_standalone " $@ " || usage
401+ get_saved_options
373402 comment_for_reflog continue
374403
375404 test -d " $DOTEST " || die " No interactive rebase running"
402431 do_rest
403432 ;;
404433 --abort)
434+ is_standalone " $@ " || usage
435+ get_saved_options
405436 comment_for_reflog abort
406437
407438 git rerere clear
419450 exit
420451 ;;
421452 --skip)
453+ is_standalone " $@ " || usage
454+ get_saved_options
422455 comment_for_reflog skip
423456
424457 git rerere clear
425458 test -d " $DOTEST " || die " No interactive rebase running"
426459
427460 output git reset --hard && do_rest
428461 ;;
429- -s|--strategy )
462+ -s)
430463 case " $# ,$1 " in
431464 * ,* =* )
432465 STRATEGY=" -s " $( expr " z$1 " : ' z-[^=]*=\(.*\)' ) ;;
437470 shift ;;
438471 esac
439472 ;;
440- -m|--merge )
473+ -m)
441474 # we use merge anyway
442475 ;;
443- -C* )
444- die " Interactive rebase uses merge, so $1 does not make sense"
445- ;;
446- -v|--verbose)
476+ -v)
447477 VERBOSE=t
448478 ;;
449- -p|--preserve-merges )
479+ -p)
450480 PRESERVE_MERGES=t
451481 ;;
452- -i|--interactive )
482+ -i)
453483 # yeah, we know
454484 ;;
455- ' ' |-h)
456- usage
485+ --onto)
486+ shift
487+ ONTO=$( git rev-parse --verify " $1 " ) ||
488+ die " Does not point to a valid commit: $1 "
457489 ;;
458- * )
490+ --)
491+ shift
492+ test $# -eq 1 -o $# -eq 2 || usage
459493 test -d " $DOTEST " &&
460494 die " Interactive rebase already started"
461495
464498
465499 comment_for_reflog start
466500
467- ONTO=
468- case " $1 " in
469- --onto)
470- ONTO=$( git rev-parse --verify " $2 " ) ||
471- die " Does not point to a valid commit: $2 "
472- shift ; shift
473- ;;
474- esac
475-
476501 require_clean_work_tree
477502
478503 UPSTREAM=$( git rev-parse --verify " $1 " ) || die " Invalid base"
0 commit comments