Subject: [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force

From: "Claus Schneider via GitGitGadget" <[email-masked]>
Date: Sat, 18 Oct 2025 20:07:14 +0000

The feature of configuring a submodule to "ignore=all" is nicely respected
in commands "status" and "diff". However the "add" command does not respect
the configuration the same way. The behavior is problematic for the logic
between status/diff and add. Secondly it makes it problematic to track
branches in the submodule configuration as developers unintentionally keeps
add submodule updates and get conflicts for no intentional reason. Both adds
unnecessary friction to the usage of submodules.

The patches implement the same logical behavior for ignore=all submodules as
regular ignored files. The status now does not show any diff - nor will the
add command update the reference submodule reference. If you add the
submodule path which is ignore=all then you are presented with a message
that you need to use the --force option. The branch=, ignore=all (and
update=none) now works great with update --remote, but developers does not
have to consider changes in the updates of the submodule sha1. The
implementation removes a friction of working with submodules and can be used
like the repo tool with branches configured. The submodule status report
could be used for build/release documentation for reproduction of a setup.

A few tests used the adding of submodules without --force, hence they have
been updated to use the --force option.

Claus Schneider(Eficode) (5):
  read-cache: update add_files_to_cache to take param
    ignored_too(--force)
  read-cache: let read-cache respect submodule ignore=all and --force
  tests: add new t2206-add-submodule-ignored.sh to test ignore=all
    scenario
  tests: fix existing tests when add an ignore=all submodule
  Documentation: update add --force and submodule ignore=all config

 Documentation/git-add.adoc       |   4 +-
 Documentation/gitmodules.adoc    |   5 +-
 builtin/add.c                    |   2 +-
 builtin/checkout.c               |   2 +-
 builtin/commit.c                 |   2 +-
 read-cache-ll.h                  |   2 +-
 read-cache.c                     |  54 ++++++++++++-
 t/lib-submodule-update.sh        |   6 +-
 t/meson.build                    |   1 +
 t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++
 t/t7508-status.sh                |   2 +-
 11 files changed, 202 insertions(+), 12 deletions(-)
 create mode 100755 t/t2206-add-submodule-ignored.sh

base-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1987
-- 
gitgitgadget