diff mbox series

[4/8] submodule update: pass --require-init and --init

Message ID 0b3d419be665186536a7350682834542647800dd.1654820781.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series submodule update: parse all options in C | expand

Commit Message

Glen Choo June 10, 2022, 12:26 a.m. UTC
From: Glen Choo <chooglen@google.com>

git-submodule.sh::cmd_update() makes "--require-init" imply "--init".
Move this logic into "git submodule--helper update" instead, and append
both options to `opts`.

Signed-off-by: Glen Choo <chooglen@google.com>
---
 builtin/submodule--helper.c | 4 ++++
 git-submodule.sh            | 9 ++-------
 2 files changed, 6 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c6c2ba1b6dc..a40f9f143e8 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2642,6 +2642,10 @@  static int module_update(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, module_update_options,
 			     git_submodule_helper_usage, 0);
 
+	if (opt.require_init) {
+		opt.init = 1;
+	}
+
 	if (filter_options.choice && !opt.init) {
 		usage_with_options(git_submodule_helper_usage,
 				   module_update_options);
diff --git a/git-submodule.sh b/git-submodule.sh
index 7418fd5bf51..f61d12ccd21 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -34,8 +34,6 @@  branch=
 force=
 cached=
 recursive=
-init=
-require_init=
 files=
 update=
 prefix=
@@ -254,11 +252,10 @@  cmd_update()
 			opts="$opts $1"
 			;;
 		-i|--init)
-			init=1
+			opts="$opts $1"
 			;;
 		--require-init)
-			init=1
-			require_init=1
+			opts="$opts $1"
 			;;
 		--remote)
 			opts="$opts $1"
@@ -344,11 +341,9 @@  cmd_update()
 
 	git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update \
 		${GIT_QUIET:+--quiet} \
-		${init:+--init} \
 		${wt_prefix:+--prefix "$wt_prefix"} \
 		${prefix:+--recursive-prefix "$prefix"} \
 		${update:+--update "$update"} \
-		${require_init:+--require-init} \
 		$opts \
 		-- \
 		"$@"