# [PATCH] submodule--helper: accept '-i' shorthand for update --init

2 messages from 2026-07-08 to 2026-07-08. Participants: Dominique Martinet, Junio C Hamano.
Thread: https://gitlist.dev/t/65952

## Dominique Martinet, 2026-07-08 03:33

Subject: [PATCH] submodule--helper: accept '-i' shorthand for update --init
Message-ID: <20260708-submodule-init-v1-1-719456077262@atmark-techno.com>

```
commit 3ad0ba722744 ("git-submodule.sh: improve variables readability")
made `git submodules update -i` pass `-i` as is to submodule--helper,
but it fails with `error: unknown switch `i'` because the helper does
not accept the short option.

All other short options supported by git-submodule.sh are properly
handle in the helper, so also add the alias for --init

Fixes: 3ad0ba722744 ("git-submodule.sh: improve variables readability")
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
This apparently can't be used much because it's been broken since v2.49,
and it's not in the help, but I guess we might as well fix this since it
used to work?

Thanks!
---
 builtin/submodule--helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1cc82a134db2..3ec8bf50532e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2990,7 +2990,7 @@ static int module_update(int argc, const char **argv, const char *prefix,
 	struct option module_update_options[] = {
 		OPT__SUPER_PREFIX(&opt.super_prefix),
 		OPT__FORCE(&opt.force, N_("force checkout updates"), 0),
-		OPT_BOOL(0, "init", &opt.init,
+		OPT_BOOL('i', "init", &opt.init,
 			 N_("initialize uninitialized submodules before update")),
 		OPT_BOOL(0, "remote", &opt.remote,
 			 N_("use SHA-1 of submodule's remote tracking branch")),

---
base-commit: 11320dd2066f2139870e36987240abc981cb493c



```

## Junio C Hamano, 2026-07-08 20:12

Subject: Re: [PATCH] submodule--helper: accept '-i' shorthand for update --init
Message-ID: <xmqq8q7ltf51.fsf@gitster.g>
In-Reply-To: <20260708-submodule-init-v1-1-719456077262@atmark-techno.com>

```
Dominique Martinet <dominique.martinet@atmark-techno.com> writes:

> commit 3ad0ba722744 ("git-submodule.sh: improve variables readability")
> made `git submodules update -i` pass `-i` as is to submodule--helper,
> but it fails with `error: unknown switch `i'` because the helper does
> not accept the short option.
>
> All other short options supported by git-submodule.sh are properly
> handle in the helper, so also add the alias for --init
>
> Fixes: 3ad0ba722744 ("git-submodule.sh: improve variables readability")
> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
> ---
> This apparently can't be used much because it's been broken since v2.49,
> and it's not in the help, but I guess we might as well fix this since it
> used to work?

3ad0ba7227 (git-submodule.sh: improve variables readability,
2024-12-11) is v2.49.0-rc0~107^2~1 and indeed we broke it and nobody
has noticed and reported since then.  An obvious alternative would
be to give a single-liner:

diff --git c/git-submodule.sh w/git-submodule.sh
index 2999b31fad..9a989edb20 100755
--- c/git-submodule.sh
+++ w/git-submodule.sh
@@ -285,7 +285,7 @@ cmd_update()
 			progress=$1
 			;;
 		-i|--init)
-			init=$1
+			init=--init
 			;;
 		--require-init)
 			require_init=$1


but since anybody should be directly running "git submodule--helper"
by hand, I think it is perfectly fine to teach it a short-option
like your patch does.

Will apply.  Thanks.

```
