Subject: Re: [PATCH 2/2] fetch: add fetch.submoduleErrors to make submodule fetch errors non-fatal

From: Jean-Noël AVILA <[email-masked]>
Date: Tue, 31 Mar 2026 18:44:49 +0200

On Monday, 30 March 2026 19:39:38 CEST Paulius Zaleckas wrote:
> When fetching with --recurse-submodules, a submodule commit that is not
> yet reachable from any of the submodule's remote refs causes the entire
> fetch to fail.  This is overly strict when the missing commit belongs to
> an upstream branch that is still being prepared (e.g. an in-progress
> merge topic): the local branch does not need that commit, so there is no
> reason to treat its absence as fatal.
> 
> Add a new config key fetch.submoduleErrors (values: fail/warn) and a
> corresponding --submodule-errors=<fail|warn> command-line option that
> control this behaviour.  The default remains fail (existing behaviour);
> setting the value to warn causes submodule fetch failures to be reported
> on stderr without affecting the overall exit status of git fetch / git
> pull.
> 
> Signed-off-by: Paulius Zaleckas <[email-masked]>
> ---
>  Documentation/config/fetch.adoc | 14 +++++
>  builtin/fetch.c                 | 39 +++++++++++++-
>  submodule.c                     |  8 ++-
>  submodule.h                     |  7 ++-
>  t/t5526-fetch-submodules.sh     | 96 +++++++++++++++++++++++++++++++++
>  5 files changed, 160 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/config/fetch.adoc b/Documentation/config/
fetch.adoc
> index cd40db0cad..8a6b68e57e 100644
> --- a/Documentation/config/fetch.adoc
> +++ b/Documentation/config/fetch.adoc
> @@ -1,3 +1,17 @@
> +`fetch.submoduleErrors`::
> +	Controls how errors from submodule fetches are handled when
> +	`--recurse-submodules` is in effect. When set to `fail` (the 
default),
> +	any submodule fetch error causes the overall `git fetch` or `git 
pull`
> +	to exit with a non-zero status. When set to `warn`, submodule fetch
> +	errors are reported to stderr but do not affect the exit status of 
the
> +	command. This is useful when working in repositories where some
> +	branches reference submodule commits that are not yet available on 
the
> +	submodule remote, but those commits are not needed for the currently
> +	checked-out branch.
> ++
> +The value of this option can be overridden on the command line with
> +`--submodule-errors=<fail|warn>`.

These `fail` and `warn` are keywords, so the alternatives must be expressed in 
synopsis style as `--submodule-errors=(fail|warn)`

I also failed to find the documentation for this `--submodule-errors` option. 
Could you add it in the relevant manual pages?

> +
>  `fetch.recurseSubmodules`::
>  	This option controls whether `git fetch` (and the underlying fetch
>  	in `git pull`) will recursively fetch into populated submodules.