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>
This commit is contained in:
Patrik Weiskircher
2025-06-04 14:16:36 +00:00
committed by Junio C Hamano
parent b07857f7dc
commit 7cd080acf6

View File

@@ -115,7 +115,7 @@ main () {
then then
set -- -h set -- -h
fi fi
set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" set_args="$(echo "$OPTS_SPEC" | git rev-parse --parseopt --stuck-long -- "$@" || echo exit $?)"
eval "$set_args" eval "$set_args"
. git-sh-setup . git-sh-setup
require_work_tree require_work_tree
@@ -131,9 +131,6 @@ main () {
opt="$1" opt="$1"
shift shift
case "$opt" in case "$opt" in
--annotate|-b|-P|-m|--onto)
shift
;;
--rejoin) --rejoin)
arg_split_rejoin=1 arg_split_rejoin=1
;; ;;
@@ -177,42 +174,37 @@ main () {
shift shift
case "$opt" in case "$opt" in
-q) --quiet)
arg_quiet=1 arg_quiet=1
;; ;;
-d) --debug)
arg_debug=1 arg_debug=1
;; ;;
--annotate) --annotate=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command" test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
arg_split_annotate="$1" arg_split_annotate="${opt#*=}"
shift
;; ;;
--no-annotate) --no-annotate)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command" test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
arg_split_annotate= arg_split_annotate=
;; ;;
-b) --branch=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command" test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
arg_split_branch="$1" arg_split_branch="${opt#*=}"
shift
;; ;;
-P) --prefix=*)
arg_prefix="${1%/}" arg_prefix="${opt#*=}"
shift
;; ;;
-m) --message=*)
test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command" test -n "$allow_addmerge" || die_incompatible_opt "$opt" "$arg_command"
arg_addmerge_message="$1" arg_addmerge_message="${opt#*=}"
shift
;; ;;
--no-prefix) --no-prefix)
arg_prefix= arg_prefix=
;; ;;
--onto) --onto=*)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command" test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"
arg_split_onto="$1" arg_split_onto="${opt#*=}"
shift
;; ;;
--no-onto) --no-onto)
test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command" test -n "$allow_split" || die_incompatible_opt "$opt" "$arg_command"