[PATCH v2] pull: document usage via OPTIONS_SPEC

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

 



Replaced USAGE and LONG_USAGE with OPTIONS_SPEC

Signed-off-by: Jay Soffian <jaysoffian@xxxxxxxxx>
---
Okay, I'm pretty sure this is correct now. make test passes, and it also
passes my "it looks right" test after having gone over it a few times.

This isn't quite ready for inclusion yet though because I want some feedback:

 * There is one semantic change. You can't use "-s=<strategy>" anymore. That's not
   really proper usage of a short option (it's either "-s<strategy>" or 
   "-s <strategy>"). Is it okay to not accept the "-s=<strategy>" form?

 * Is it worth doing this at all? If the plan is to rewrite everything as
   builtins I kinda feel like I'm wasting my time. If not, I'll work on doing
   this for all the other scripts which are missing an OPTIONS_SPEC. Then maybe
   they can all be merged at once?

 * You can see I added the GIT_PULL_DEBUG_ARGS blob. Frankly, I can't really
   think of a good way to test this change other than to do something like that
   and then add a test for each individual option. But that's going to really
   bloat the test suite. Is it worth it to do this for every script? Or is
   passing the existing test suite and enough eyeballs looking at it in next
   good enough? Can you think of another way to check for regressions?

j.

 git-pull.sh |   94 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index 3ce32b5..8b1d732 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -4,10 +4,36 @@
 #
 # Fetch one or more remote refs and merge it/them into the current HEAD.
 
-USAGE='[-n | --no-summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
-LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
 SUBDIRECTORY_OK=Yes
-OPTIONS_SPEC=
+OPTIONS_SPEC="\
+git pull [options] [<repo>] [<refspec>]
+--
+  fetch options
+q,quiet          make the fetch process less verbose
+v,verbose        make the fetch process more verbose
+a,append         append to FETCH_HEAD instead of overwritting
+upload-pack=,    specify path to git-fetch-pack on remote end
+f,force          force local branch to be updated by remote branch
+t,tags           fetch all remote tags
+no-tags          do not fetch any remote tags
+k,keep           keep downloaded pack
+u,update-head-ok used internally between git pull and git fetch
+depth=           deep shallow history by specified number of commits
+  merge options
+summary          show diffstat at end of merge
+n,no-summary     do not show diff stat at end of merge
+commit           commit the result after merging
+no-commit        do not commit the result after merging
+squash           update the index and working tree only
+no-squash        override --squash, perform a normal merge and commit
+ff               only update branch pointer if merge is a fast-forward
+no-ff            do a merge commit even if the merge is a fast-forward
+s,strategy=      use given merge strategy
+  rebase options
+rebase           rebase after fetching
+no-rebase        merge after fetching
+s,strategy=      use given merge strategy; implies -m to rebase
+"
 . git-sh-setup
 set_reflog_action "pull $*"
 require_work_tree
@@ -23,46 +49,33 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
 while :
 do
 	case "$1" in
-	-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
-		--no-summa|--no-summar|--no-summary)
+	-n|--no-summary)
 		no_summary=-n ;;
 	--summary)
-		no_summary=$1
-		;;
-	--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
+		no_summary=$1 ;;
+	--no-commit)
 		no_commit=--no-commit ;;
-	--c|--co|--com|--comm|--commi|--commit)
+	--commit)
 		no_commit=--commit ;;
-	--sq|--squ|--squa|--squas|--squash)
+	--squash)
 		squash=--squash ;;
-	--no-sq|--no-squ|--no-squa|--no-squas|--no-squash)
+	--no-squash)
 		squash=--no-squash ;;
 	--ff)
 		no_ff=--ff ;;
 	--no-ff)
 		no_ff=--no-ff ;;
-	-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
-		strategy_args="${strategy_args}-s $strategy "
-		;;
-	-r|--r|--re|--reb|--reba|--rebas|--rebase)
-		rebase=true
-		;;
-	--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
-		rebase=false
+	-s|--strategy)
+		shift
+		strategy_args="${strategy_args}-s $1 "
 		;;
-	-h|--h|--he|--hel|--help)
-		usage
+	-r|--rebase)
+		rebase=true ;;
+	--no-rebase)
+		rebase=false ;;
+	--)
+		shift
+		break
 		;;
 	*)
 		# Pass thru anything that may be meant for fetch.
@@ -72,12 +85,27 @@ do
 	shift
 done
 
+test '' != "$GIT_PULL_DEBUG_ARGS" && {
+	exec >&2
+	for var in strategy_args no_summary no_commit squash no_ff rebase
+	do
+		echo "$var='$(eval echo "\$$var")'"
+	done
+	argnum=1
+	for opt
+	do
+		echo "$argnum='$opt'"
+		argnum=$(($argnum + 1))
+	done
+	exit 0
+}
+
 error_on_no_merge_candidates () {
 	exec >&2
 	for opt
 	do
 		case "$opt" in
-		-t|--t|--ta|--tag|--tags)
+		-t|--tags)
 			echo "Fetching tags only, you probably meant:"
 			echo "  git fetch --tags"
 			exit 1
-- 
1.5.4.3.345.g651f8

-
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]

  Powered by Linux