git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 05/10] git-submodule.sh: dispatch "update" to helper

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 17, 2022, 12:09 UTC
Message-ID
<patch-05.10-7d9c13eb637-20221017T115544Z-avarab@gmail.com>
In-Reply-To
<cover-00.10-00000000000-20221017T115544Z-avarab@gmail.com>

Dispatch the "update" command directly to "git submodule--helper update", rather than doing our own argument parsing in git-submodule.sh. As this is the last cmd_*() function to be removed from git-submodule.sh we can do some larger cleanup of that file as a result.

As noted in a preceding commit the only behavior change here should be the desirable change of better "-h" output, and that this implementation understands the "--verbose" synonym for "-v". Let's update the documentation to reflect the new "--verbose" synonym.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 git-submodule.sh | 156 +----------------------------------------------
 1 file changed, 2 insertions(+), 154 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 7874e33beea..ac2f95c1285 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -31,160 +31,7 @@ export GIT_PROTOCOL_FROM_USER
 
 command=
 quiet=
-force=
-reference=
 cached=
-recursive=
-init=
-require_init=
-remote=
-nofetch=
-rebase=
-merge=
-checkout=
-depth=
-progress=
-dissociate=
-single_branch=
-jobs=
-recommend_shallow=
-filter=
-
-#
-# Update each submodule path to correct revision, using clone and checkout as needed
-#
-# $@ = requested paths (default to all)
-#
-cmd_update()
-{
-	# parse $args after "submodule ... update".
-	while test $# -ne 0
-	do
-		case "$1" in
-		-q|--quiet)
-			quiet=1
-			;;
-		--progress)
-			progress=1
-			;;
-		-i|--init)
-			init=1
-			;;
-		--require-init)
-			require_init=1
-			;;
-		--remote)
-			remote=1
-			;;
-		-N|--no-fetch)
-			nofetch=1
-			;;
-		-f|--force)
-			force=$1
-			;;
-		-r|--rebase)
-			rebase=1
-			;;
-		--reference)
-			case "$2" in '') usage ;; esac
-			reference="--reference=$2"
-			shift
-			;;
-		--reference=*)
-			reference="$1"
-			;;
-		--dissociate)
-			dissociate=1
-			;;
-		-m|--merge)
-			merge=1
-			;;
-		--recursive)
-			recursive=1
-			;;
-		--checkout)
-			checkout=1
-			;;
-		--recommend-shallow)
-			recommend_shallow="--recommend-shallow"
-			;;
-		--no-recommend-shallow)
-			recommend_shallow="--no-recommend-shallow"
-			;;
-		--depth)
-			case "$2" in '') usage ;; esac
-			depth="--depth=$2"
-			shift
-			;;
-		--depth=*)
-			depth=$1
-			;;
-		-j|--jobs)
-			case "$2" in '') usage ;; esac
-			jobs="--jobs=$2"
-			shift
-			;;
-		--jobs=*)
-			jobs=$1
-			;;
-		--single-branch)
-			single_branch="--single-branch"
-			;;
-		--no-single-branch)
-			single_branch="--no-single-branch"
-			;;
-		--filter)
-			case "$2" in '') usage ;; esac
-			filter="--filter=$2"
-			shift
-			;;
-		--filter=*)
-			filter="$1"
-			;;
-		--)
-			shift
-			break
-			;;
-		-*)
-			usage
-			;;
-		*)
-			break
-			;;
-		esac
-		shift
-	done
-
-	git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \
-		${quiet:+--quiet} \
-		${force:+--force} \
-		${progress:+"--progress"} \
-		${remote:+--remote} \
-		${recursive:+--recursive} \
-		${init:+--init} \
-		${nofetch:+--no-fetch} \
-		${wt_prefix:+--prefix "$wt_prefix"} \
-		${rebase:+--rebase} \
-		${merge:+--merge} \
-		${checkout:+--checkout} \
-		${reference:+"$reference"} \
-		${dissociate:+"--dissociate"} \
-		${depth:+"$depth"} \
-		${require_init:+--require-init} \
-		${dissociate:+"--dissociate"} \
-		$single_branch \
-		$recommend_shallow \
-		$jobs \
-		$filter \
-		-- \
-		"$@"
-}
-
-# This loop parses the command line arguments to find the
-# subcommand name to dispatch.  Parsing of the subcommand specific
-# options are primarily done by the subcommand implementations.
-# Subcommand specific options such as --branch and --cached are
-# parsed here as well, for backward compatibility.
 
 while test $# != 0 && test -z "$command"
 do
@@ -233,7 +80,8 @@ absorbgitdirs)
 	git submodule--helper "$command" --prefix "$wt_prefix" "$@"
 	;;
 update)
-	cmd_update "$@"
+	git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \
+		${quiet:+--quiet} ${wt_prefix:+--prefix "$wt_prefix"} "$@"
 	;;
 add | foreach | init | deinit | set-branch | set-url | status | summary | sync)
 	git ${wt_prefix:+-C "$wt_prefix"} submodule--helper "$command" \
-- 
2.38.0.1091.gf9d18265e59
Previous: Glen ChooNext: Glen Choo
Message 10 of 18 in “submodule: make it a built-in, remove git-submodule.sh”
  1. 00/10 submodule: make it a built-in, remove git-submodule.shÆvar Arnfjörð Bjarmason, Oct 17, 2022
  2. 01/10 git-submodule.sh: create a "case" dispatch statementÆvar Arnfjörð Bjarmason, Oct 17, 2022
  3. 02/10 git-submodule.sh: dispatch "sync" to helperÆvar Arnfjörð Bjarmason, Oct 17, 2022
  4. Glen ChooOct 20, 2022
  5. 04/10 git-submodule.sh: dispatch "foreach" to helperÆvar Arnfjörð Bjarmason, Oct 17, 2022
  6. Glen ChooOct 20, 2022
  7. 03/10 git-submodule.sh: dispatch directly to helperÆvar Arnfjörð Bjarmason, Oct 17, 2022
  8. 06/10 git-submodule.sh: don't support top-level "--cached"Ævar Arnfjörð Bjarmason, Oct 17, 2022
  9. Glen ChooOct 20, 2022
  10. 05/10 git-submodule.sh: dispatch "update" to helperÆvar Arnfjörð Bjarmason, Oct 17, 2022
  11. Glen ChooOct 20, 2022
  12. 08/10 submodule: support "--" with no other argumentsÆvar Arnfjörð Bjarmason, Oct 17, 2022
  13. 09/10 submodule: support sub-command-less "--recursive" optionÆvar Arnfjörð Bjarmason, Oct 17, 2022
  14. Glen ChooOct 20, 2022
  15. 07/10 submodule: make it a built-in, remove git-submodule.shÆvar Arnfjörð Bjarmason, Oct 17, 2022
  16. Glen ChooOct 20, 2022
  17. 10/10 submodule: don't use a subprocess to invoke "submodule--helper"Ævar Arnfjörð Bjarmason, Oct 17, 2022
  18. Glen ChooOct 20, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.