git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Claus Schneider via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Brandon Williams <bmwill@google.com>,
	Claus Schneider <claus.schneider@eficode.com>,
	Emily Shaffer <emilyshaffer@google.com>
Subject: Re: [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force
Date: Sun, 19 Oct 2025 16:34:19 +0100	[thread overview]
Message-ID: <2688a523-e324-41bb-858f-b32040e1e909@gmail.com> (raw)
In-Reply-To: <pull.1987.git.1760818039.gitgitgadget@gmail.com>

Hi Claus

[I've adjusted the CC list slightly]

On 18/10/2025 21:07, Claus Schneider via GitGitGadget wrote:
> 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.

I was curious why, when "git add" uses the same machinery as "git diff" 
to figure out which paths need updating, it behaves differently. It 
turns out that add_files_to_cache() contains

	rev.diffopt.flags.override_submodule_config = 1;

which makes "git add" ignore "submodule.<name>.ignore". Tracing the 
history of this line, it originates from 5556808690e (add, reset: ensure 
submodules can be added or reset, 2017-07-25) which made a deliberate 
choice for both "git add" and "git reset" not to behave like "git diff". 
If we're going to change the behavior then it would be helpful to 
explain how this patch series ameliorates the concerns that lead to that 
commit and why it is sensible to change the behavior of "git add" but 
not "git reset". It also suggests that a much simpler way of 
implementing the change would be to delete that line.

I'm not convinced that the approach of using "--force" is a good idea as 
it conflates ignoring changes to tracked paths (which is what 
submodule.<name>.ignore" does) with ignoring untracked paths (which is 
what ".gitignore" does). If we're happy to break existing uses that rely 
on the current behavior then having a new option to override 
submodule.<name>.ignore strikes me as a better way forward. I don't have 
much experience of using submodules so I can't comment on whether 
changing the behavior is a good idea or not.

Thanks

Phillip


  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


  parent reply	other threads:[~2025-10-19 15:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-18 20:07 [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force Claus Schneider via GitGitGadget
2025-10-18 20:07 ` [PATCH 1/5] read-cache: update add_files_to_cache to take param ignored_too(--force) Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 2/5] read-cache: let read-cache respect submodule ignore=all and --force Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 3/5] tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 4/5] tests: fix existing tests when add an ignore=all submodule Claus Schneider(Eficode) via GitGitGadget
2025-10-18 20:07 ` [PATCH 5/5] Documentation: update add --force and submodule ignore=all config Claus Schneider(Eficode) via GitGitGadget
2025-10-19 15:34 ` Phillip Wood [this message]
     [not found]   ` <CA+GP4bpu3SUycG35DU5+NSuiqtfYN9-R=7d01EFhexgGh4sRPg@mail.gmail.com>
2025-10-20  7:28     ` [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force Claus Schneider
     [not found]   ` <CA+GP4bqb775U5oBbLZg1dou+THJOjTbFN+2Pq1cBPqq1SgbxHw@mail.gmail.com>
2025-10-24 13:55     ` Phillip Wood
2025-11-13 12:51       ` Claus Schneider
2025-11-13 18:10 ` [PATCH v2 " Claus Schneider via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 1/5] read-cache: update add_files_to_cache take param include_ignored_submodules Claus Schneider(Eficode) via GitGitGadget
2025-11-13 22:07     ` Junio C Hamano
2025-11-13 18:10   ` [PATCH v2 2/5] read-cache: add/read-cache respect submodule ignore=all Claus Schneider(Eficode) via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 3/5] tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario Claus Schneider(Eficode) via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 4/5] tests: fix existing tests when add an ignore=all submodule Claus Schneider(Eficode) via GitGitGadget
2025-11-13 18:10   ` [PATCH v2 5/5] Documentation: add --include_ignored_submodules + ignore=all config Claus Schneider(Eficode) via GitGitGadget
2025-11-13 19:58   ` [PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force Junio C Hamano
2025-11-14 13:53     ` Claus Schneider

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2688a523-e324-41bb-858f-b32040e1e909@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=bmwill@google.com \
    --cc=claus.schneider@eficode.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).