contrib/subtree: parse using --stuck-long
Optional parameter handling only works unambiguous with git rev-parse --parseopt when using the --stuck-long option. To prepare for future commits which add flags with optional parameters, parse with --stuck-long. Signed-off-by: Patrik Weiskircher <patrik@pspdfkit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrik Weiskircher committed
Jun 4, 2025 at 14:16 UTC
7cd080acf65a96032824f3b5faad506346b69f5c
1 file changed
+13
-21
contrib/subtree/git-subtree.sh
+13
-21
@@ -115,7 +115,7 @@ main () {
115
then
116
set -- -h
117
fi
118
- set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
118
+ set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt --stuck-long -- "$@" || echo exit $?)"
119
eval "$set_args"
120
. git-sh-setup
121
require_work_tree
@@ -131,9 +131,6 @@ main () {
131
opt="$1"
132
shift
133
case "$opt" in
134
- --annotate|-b|-P|-m|--onto)
135
- shift
136
- ;;
134
--rejoin)
135
arg_split_rejoin=1
136
;;
@@ -177,42 +174,37 @@ main () {
174
shift
175
176
case "$opt" in
180
- -q)
177
+ --quiet)
178
arg_quiet=1
179
;;
183
- -d)
180
+ --debug)
181
arg_debug=1
182
;;
186
- --annotate)
183
+ --annotate=*)
184
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
188
- arg_split_annotate="$1"
189
- shift
185
+ arg_split_annotate="${opt#*=}"
186
;;
187
--no-annotate)
188
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
189
arg_split_annotate=
190
;;
195
- -b)
191
+ --branch=*)
192
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
197
- arg_split_branch="$1"
198
- shift
193
+ arg_split_branch="${opt#*=}"
194
;;
200
- -P)
201
- arg_prefix="${1%/}"
202
- shift
195
+ --prefix=*)
196
+ arg_prefix="${opt#*=}"
197
;;
204
- -m)
198
+ --message=*)
199
test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command"
206
- arg_addmerge_message="$1"
207
- shift
200
+ arg_addmerge_message="${opt#*=}"
201
;;
202
--no-prefix)
203
arg_prefix=
204
;;
212
- --onto)
205
+ --onto=*)
206
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
214
- arg_split_onto="$1"
215
- shift
207
+ arg_split_onto="${opt#*=}"
208
;;
209
--no-onto)
210
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"