Make rebase--interactive use OPTIONS_SPEC
Also add some checks that --continue/--abort/--skip actions are used without --onto, -p, -t, etc. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephan Beyer committed
Jul 12, 2008 at 17:48 UTC
7970aaf0fb65ad3e9f61d0ede6f211125732495d
1 file changed
+51
-26
git-rebase--interactive.sh
+51
-26
@@ -10,10 +10,24 @@
10
# The original idea comes from Eric W. Biederman, in
11
# http://article.gmane.org/gmane.comp.version-control.git/22407
12
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
+"
30
16
-OPTIONS_SPEC=
31
. git-sh-setup
32
require_work_tree
33
@@ -25,10 +39,8 @@ SQUASH_MSG="$DOTEST"/message-squash
39
REWRITTEN="$DOTEST"/rewritten
40
PRESERVE_MERGES=
41
STRATEGY=
42
+ONTO=
43
VERBOSE=
29
-test -d "$REWRITTEN" && PRESERVE_MERGES=t
30
-test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
31
-test -f "$DOTEST"/verbose && VERBOSE=t
44
45
GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
46
mark the corrected paths with 'git add <paths>', and
@@ -366,10 +378,27 @@ do_rest () {
378
done
379
}
380
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
+
396
while test $# != 0
397
do
398
case "$1" in
399
--continue)
400
+ is_standalone "$@" || usage
401
+ get_saved_options
402
comment_for_reflog continue
403
404
test -d "$DOTEST" || die "No interactive rebase running"
@@ -402,6 +431,8 @@ do
431
do_rest
432
;;
433
--abort)
434
+ is_standalone "$@" || usage
435
+ get_saved_options
436
comment_for_reflog abort
437
438
git rerere clear
@@ -419,6 +450,8 @@ do
450
exit
451
;;
452
--skip)
453
+ is_standalone "$@" || usage
454
+ get_saved_options
455
comment_for_reflog skip
456
457
git rerere clear
@@ -426,7 +459,7 @@ do
459
460
output git reset --hard && do_rest
461
;;
429
- -s|--strategy)
462
+ -s)
463
case "$#,$1" in
464
*,*=*)
465
STRATEGY="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
@@ -437,25 +470,26 @@ do
470
shift ;;
471
esac
472
;;
440
- -m|--merge)
473
+ -m)
474
# we use merge anyway
475
;;
443
- -C*)
444
- die "Interactive rebase uses merge, so $1 does not make sense"
445
- ;;
446
- -v|--verbose)
476
+ -v)
477
VERBOSE=t
478
;;
449
- -p|--preserve-merges)
479
+ -p)
480
PRESERVE_MERGES=t
481
;;
452
- -i|--interactive)
482
+ -i)
483
# yeah, we know
484
;;
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"
489
;;
458
- *)
490
+ --)
491
+ shift
492
+ test $# -eq 1 -o $# -eq 2 || usage
493
test -d "$DOTEST" &&
494
die "Interactive rebase already started"
495
@@ -464,15 +498,6 @@ do
498
499
comment_for_reflog start
500
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
-
501
require_clean_work_tree
502
503
UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"