[PATCH 2/5] git-merge: refactor option parsing

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <gitster@...>
Cc: <git@...>
Date: Friday, September 21, 2007 - 8:33 pm

Move the option parsing into a separate function as preparation for reuse
by the next commit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 git-merge.sh |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/git-merge.sh b/git-merge.sh
index 3a01db0..a3ef676 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -119,11 +119,7 @@ merge_name () {
 	fi
 }
 
-case "$#" in 0) usage ;; esac
-
-have_message=
-while case "$#" in 0) break ;; esac
-do
+parse_option () {
 	case "$1" in
 	-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
 		--no-summa|--no-summar|--no-summary)
@@ -166,9 +162,21 @@ do
 		have_message=t
 		;;
 	-*)	usage ;;
-	*)	break ;;
+	*)	return 1 ;;
 	esac
 	shift
+	args_left="$#"
+}
+
+case "$#" in 0) usage ;; esac
+
+have_message=
+while parse_option "$@"
+do
+	while test $args_left -lt $#
+	do
+		shift
+	done
 done
 
 if test -z "$show_diffstat"; then
-- 
1.5.3.2.82.g75c8d

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/5] Add test-script for git-merge porcelain, Lars Hjemli, (Fri Sep 21, 8:33 pm)
[PATCH 2/5] git-merge: refactor option parsing, Lars Hjemli, (Fri Sep 21, 8:33 pm)
[PATCH 4/5] git-merge: add support for --commit, Lars Hjemli, (Fri Sep 21, 8:33 pm)
[PATCH 5/5] git-merge: add --ff and --no-ff options, Lars Hjemli, (Fri Sep 21, 8:33 pm)