git-submodule.sh: get rid of isnumber
It's entirely unnecessary to check whether the argument given to an option (i.e. --summary-limit) is valid in the shell wrapper, since it's already done when parsing the various options in git-submodule--helper. Remove this check from the script; this both improves consistency throughout the script, and the error message shown to the user in case some invalid non-numeric argument was passed to "--summary-limit" is more informative as well. 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
006f546bc30bd42de6ba569ab70ec80441f54430
1 file changed
+2
-9
git-submodule.sh
+2
-9
@@ -53,11 +53,6 @@ jobs=
53
recommend_shallow=
54
filter=
55
56
-isnumber()
57
-{
58
- n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1"
59
-}
60
-
56
#
57
# Add a new submodule to the working tree, .gitmodules and the index
58
#
@@ -524,17 +519,15 @@ cmd_summary() {
519
for_status="$1"
520
;;
521
-n|--summary-limit)
522
+ case "$2" in '') usage ;; esac
523
summary_limit="$2"
528
- isnumber "$summary_limit" || usage
524
shift
525
;;
526
-n*)
527
summary_limit="${1#-n}"
533
- isnumber "$summary_limit" || usage
528
;;
529
--summary-limit=*)
530
summary_limit="${1#--summary-limit=}"
537
- isnumber "$summary_limit" || usage
531
;;
532
--)
533
shift
@@ -554,7 +547,7 @@ cmd_summary() {
547
${files:+--files} \
548
${cached:+--cached} \
549
${for_status:+--for-status} \
557
- ${summary_limit:+-n $summary_limit} \
550
+ ${summary_limit:+-n "$summary_limit"} \
551
-- \
552
"$@"
553
}