[PATCH] rebase: define options in OPTIONS_SPEC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Also improve the usage message to contain the --continue, --skip and
--abort commands.
---

Applies on top of mz/rebase.

Are USAGE and LONG_USAGE still needed?

I based the definitions on the now-lost OPTIONS_SPEC from interactive
rebase. I added some descriptions that were not too hard to describe
in a concise way. The rest, I simply hid (with the "*" marker). Should
the list be exhaustive?

What is the difference between the "options" and "actions" sections?

 git-rebase.sh |  104 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 59 insertions(+), 45 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index a040ab5..7857059 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -28,7 +28,42 @@ Example:       git-rebase master~1 topic
 '
 
 SUBDIRECTORY_OK=Yes
-OPTIONS_SPEC=
+OPTIONS_KEEPDASHDASH=
+OPTIONS_SPEC="\
+git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]
+git rebase [-i] [options] --onto <newbase> --root [<branch>]
+git-rebase [-i] --continue | --abort | --skip
+--
+ Available options are
+v,verbose          display a diffstat of what changed upstream
+q,quiet            be quiet. implies --no-stat
+onto=              rebase onto given branch instead of upstream
+p,preserve-merges  try to recreate merges instead of ignoring them
+s,strategy=        use the given merge strategy
+no-ff              cherry-pick all commits, even if unchanged
+m,merge            use merging strategies to rebase
+i,interactive      let the user edit the list of commits to rebase
+f,force-rebase*    -
+X,strategy-option= pass the argument through to the merge strategy
+stat*              -
+n,no-stat*         -
+whitespace=*       -
+ignore-whitespace* -
+committer-date-is-author-date* -
+ignore-date*       -
+C=*                -
+rerere-autoupdate* -
+no-rerere-autoupdate* -
+ Actions:
+continue           continue rebasing process
+abort              abort rebasing process and restore original branch
+skip               skip current patch and continue rebasing process
+no-verify          override pre-rebase hook from stopping the operation
+verify             allow pre-rebase hook to run
+root               rebase all reachable commmits up to the root(s)
+autosquash         move commits that begin with squash!/fixup! under -i
+no-autosquash*     -
+"
 . git-sh-setup
 set_reflog_action rebase
 require_work_tree
@@ -175,7 +210,7 @@ do
 		ok_to_skip_pre_rebase=
 		;;
 	--continue|--skip|--abort)
-		test $total_argc -eq 1 || usage
+		test $total_argc -eq 2 || usage
 		action=${1##--}
 		;;
 	--onto)
@@ -183,10 +218,10 @@ do
 		onto="$2"
 		shift
 		;;
-	-i|--interactive)
+	-i)
 		interactive_rebase=explicit
 		;;
-	-p|--preserve-merges)
+	-p)
 		preserve_merges=t
 		test -z "$interactive_rebase" && interactive_rebase=implied
 		;;
@@ -196,62 +231,42 @@ do
 	--no-autosquash)
 		autosquash=
 		;;
-	-M|-m|--m|--me|--mer|--merg|--merge)
+	-M|-m)
 		do_merge=t
 		;;
-	-X*|--strategy-option*)
-		case "$#,$1" in
-		1,-X|1,--strategy-option)
-			usage ;;
-		*,-X|*,--strategy-option)
-			newopt="$2"
-			shift ;;
-		*,--strategy-option=*)
-			newopt="$(expr " $1" : ' --strategy-option=\(.*\)')" ;;
-		*,-X*)
-			newopt="$(expr " $1" : ' -X\(.*\)')" ;;
-		1,*)
-			usage ;;
-		esac
-		strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
+	-X)
+		shift
+		strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$1")"
 		do_merge=t
 		test -z "$strategy" && strategy=recursive
 		;;
-	-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
-		--strateg=*|--strategy=*|\
-	-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
-		case "$#,$1" in
-		*,*=*)
-			strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;;
-		1,*)
-			usage ;;
-		*)
-			strategy="$2"
-			shift ;;
-		esac
+	-s)
+		shift
+		strategy="$1"
 		do_merge=t
 		;;
-	-n|--no-stat)
+	-n)
 		diffstat=
 		;;
 	--stat)
 		diffstat=t
 		;;
-	-v|--verbose)
+	-v)
 		verbose=t
 		diffstat=t
 		GIT_QUIET=
 		;;
-	-q|--quiet)
+	-q)
 		GIT_QUIET=t
 		git_am_opt="$git_am_opt -q"
 		verbose=
 		diffstat=
 		;;
-	--whitespace=*)
-		git_am_opt="$git_am_opt $1"
+	--whitespace)
+		shift
+		git_am_opt="$git_am_opt --whitespace=$1"
 		case "$1" in
-		--whitespace=fix|--whitespace=strip)
+		fix|strip)
 			force_rebase=t
 			;;
 		esac
@@ -263,22 +278,21 @@ do
 		git_am_opt="$git_am_opt $1"
 		force_rebase=t
 		;;
-	-C*)
-		git_am_opt="$git_am_opt $1"
+	-C)
+		shift
+		git_am_opt="$git_am_opt -C$1"
 		;;
 	--root)
 		rebase_root=t
 		;;
-	-f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)
+	-f|--no-ff)
 		force_rebase=t
 		;;
 	--rerere-autoupdate|--no-rerere-autoupdate)
 		allow_rerere_autoupdate="$1"
 		;;
-	-*)
-		usage
-		;;
-	*)
+	--)
+		shift
 		break
 		;;
 	esac
-- 
1.7.4.1.79.gba571.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]