git-submodule.sh: improve parsing of short options

Some command-line options have a short form which takes an argument; for example, "--jobs" has the form "-j", and it takes a numerical argument. When parsing short options, support the case where there is no space between the flag and the option argument, in order to improve consistency with the rest of the builtin git commands. Signed-off-by: Roy Eldar <royeldar0@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Roy Eldar committed Dec 11, 2024 at 08:32 UTC e6c3e349458ec2ad36addc6004cffcfa6d663c38
1 file changed +13
git-submodule.sh
+13
@@ -77,6 +77,9 @@ cmd_add()
77 branch=$2
78 shift
79 ;;
80 + -b*)
81 + branch="${1#-b}"
82 + ;;
83 --branch=*)
84 branch="${1#--branch=}"
85 ;;
@@ -352,6 +355,9 @@ cmd_update()
355 jobs="--jobs=$2"
356 shift
357 ;;
358 + -j*)
359 + jobs="--jobs=${1#-j}"
360 + ;;
361 --jobs=*)
362 jobs=$1
363 ;;
@@ -431,6 +437,9 @@ cmd_set_branch() {
437 branch=$2
438 shift
439 ;;
440 + -b*)
441 + branch="${1#-b}"
442 + ;;
443 --branch=*)
444 branch="${1#--branch=}"
445 ;;
@@ -519,6 +528,10 @@ cmd_summary() {
528 isnumber "$summary_limit" || usage
529 shift
530 ;;
531 + -n*)
532 + summary_limit="${1#-n}"
533 + isnumber "$summary_limit" || usage
534 + ;;
535 --summary-limit=*)
536 summary_limit="${1#--summary-limit=}"
537 isnumber "$summary_limit" || usage