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

Migrate git-merge.sh to use git-rev-parse --parseopt

Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pierre Habouzit committed Nov 4, 2007 at 11:30 UTC b0bf1d8b7952d6119b0737b80873c987fdc75e55
1 file changed +54 -72
git-merge.sh
+54 -72
@@ -3,7 +3,19 @@
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 -USAGE='[-n] [--summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s <strategy>] [-m=<merge-message>] <commit>+'
6 +OPTIONS_KEEPDASHDASH=
7 +OPTIONS_SPEC="\
8 +git-merge [options] <remote>...
9 +git-merge [options] <msg> HEAD <remote>
10 +--
11 +summary show a diffstat at the end of the merge
12 +n,no-summary don't show a diffstat at the end of the merge
13 +squash create a single commit instead of doing a merge
14 +commit perform a commit if the merge sucesses (default)
15 +ff allow fast forward (default)
16 +s,strategy= merge strategy to use
17 +m,message= message to be used for the merge commit (if any)
18 +"
19
20 SUBDIRECTORY_OK=Yes
21 . git-sh-setup
@@ -133,72 +145,47 @@ merge_name () {
145 fi
146 }
147
136 -parse_option () {
137 - case "$1" in
138 - -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
139 - --no-summa|--no-summar|--no-summary)
140 - show_diffstat=false ;;
141 - --summary)
142 - show_diffstat=t ;;
143 - --sq|--squ|--squa|--squas|--squash)
144 - allow_fast_forward=t squash=t no_commit=t ;;
145 - --no-sq|--no-squ|--no-squa|--no-squas|--no-squash)
146 - allow_fast_forward=t squash= no_commit= ;;
147 - --c|--co|--com|--comm|--commi|--commit)
148 - allow_fast_forward=t squash= no_commit= ;;
149 - --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
150 - allow_fast_forward=t squash= no_commit=t ;;
151 - --ff)
152 - allow_fast_forward=t squash= no_commit= ;;
153 - --no-ff)
154 - allow_fast_forward=false squash= no_commit= ;;
155 - -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
156 - --strateg=*|--strategy=*|\
157 - -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
158 - case "$#,$1" in
159 - *,*=*)
160 - strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;;
161 - 1,*)
162 - usage ;;
163 - *)
164 - strategy="$2"
165 - shift ;;
166 - esac
167 - case " $all_strategies " in
168 - *" $strategy "*)
169 - use_strategies="$use_strategies$strategy " ;;
170 - *)
171 - die "available strategies are: $all_strategies" ;;
172 - esac
173 - ;;
174 - -m=*|--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)
175 - merge_msg=`expr "z$1" : 'z-[^=]*=\(.*\)'`
176 - have_message=t
177 - ;;
178 - -m|--m|--me|--mes|--mess|--messa|--messag|--message)
179 - shift
180 - case "$#" in
181 - 1) usage ;;
182 - esac
183 - merge_msg="$1"
184 - have_message=t
185 - ;;
186 - -*) usage ;;
187 - *) return 1 ;;
188 - esac
189 - shift
190 - args_left=$#
191 -}
192 -
148 parse_config () {
194 - while test $# -gt 0
195 - do
196 - parse_option "$@" || usage
197 - while test $args_left -lt $#
198 - do
149 + while test $# != 0; do
150 + case "$1" in
151 + -n|--no-summary)
152 + show_diffstat=false ;;
153 + --summary)
154 + show_diffstat=t ;;
155 + --squash)
156 + allow_fast_forward=t squash=t no_commit=t ;;
157 + --no-squash)
158 + allow_fast_forward=t squash= no_commit= ;;
159 + --commit)
160 + allow_fast_forward=t squash= no_commit= ;;
161 + --no-commit)
162 + allow_fast_forward=t squash= no_commit=t ;;
163 + --ff)
164 + allow_fast_forward=t squash= no_commit= ;;
165 + --no-ff)
166 + allow_fast_forward=false squash= no_commit= ;;
167 + -s|--strategy)
168 + shift
169 + case " $all_strategies " in
170 + *" $1 "*)
171 + use_strategies="$use_strategies$1 " ;;
172 + *)
173 + die "available strategies are: $all_strategies" ;;
174 + esac
175 + ;;
176 + -m|--message)
177 shift
200 - done
178 + merge_msg="$1"
179 + have_message=t
180 + ;;
181 + --)
182 + shift
183 + break ;;
184 + *) usage ;;
185 + esac
186 + shift
187 done
188 + args_left=$#
189 }
190
191 test $# != 0 || usage
@@ -210,17 +197,12 @@ then
197 mergeopts=$(git config "branch.${branch#refs/heads/}.mergeoptions")
198 if test -n "$mergeopts"
199 then
213 - parse_config $mergeopts
200 + parse_config $mergeopts --
201 fi
202 fi
203
217 -while parse_option "$@"
218 -do
219 - while test $args_left -lt $#
220 - do
221 - shift
222 - done
223 -done
204 +parse_config "$@"
205 +while test $args_left -lt $#; do shift; done
206
207 if test -z "$show_diffstat"; then
208 test "$(git config --bool merge.diffstat)" = false && show_diffstat=false