@matheusbsbs / matheus-bagliano / commits / d38eb710d9
Fork 0

git-merge: refactor option parsing

Move the option parsing into a separate function as preparation for reuse by the next commit. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lars Hjemli committed Sep 24, 2007 at 00:51 UTC d38eb710d92864b0b1f7cd36f17e273e3d8c735c
1 file changed +14 -6
git-merge.sh
+14 -6
@@ -119,11 +119,7 @@ merge_name () {
119 fi
120 }
121
122 -case "$#" in 0) usage ;; esac
123 -
124 -have_message=
125 -while test $# != 0
126 -do
122 +parse_option () {
123 case "$1" in
124 -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
125 --no-summa|--no-summar|--no-summary)
@@ -166,9 +162,21 @@ do
162 have_message=t
163 ;;
164 -*) usage ;;
169 - *) break ;;
165 + *) return 1 ;;
166 esac
167 shift
168 + args_left=$#
169 +}
170 +
171 +test $# != 0 || usage
172 +
173 +have_message=
174 +while parse_option "$@"
175 +do
176 + while test $args_left -lt $#
177 + do
178 + shift
179 + done
180 done
181
182 if test -z "$show_diffstat"; then