git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Oct 24, 2025, 13:55 UTC
Message-ID
<63d07c3c-ac4b-4ef9-ad90-d79f00cc7ca9@gmail.com>
In-Reply-To
<CA+GP4bqb775U5oBbLZg1dou+THJOjTbFN+2Pq1cBPqq1SgbxHw@mail.gmail.com>
Hi Claus
On 19/10/2025 22:39, Claus Schneider wrote:
Show 13 quoted lines
> On Sun, Oct 19, 2025, 17:34 Phillip Wood <phillip.wood123@gmail.com 
> <mailto:phillip.wood123@gmail.com>> wrote:
> 
>> 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".
> Thank you for your feedback and for investigating this. I was not aware > of the setting that causes `add` and `reset` to override submodule 
> configuration, and I will need to look into `reset` further.

You should mention the commit that added the current behavior and the reason it was added in the commit message where you change the behavior.

Show 7 quoted lines
> I understand the problematic aspect of not being able to add an update 
> of a submodule reference, which likely led to the overwrite setting. 
> From a Git developer's perspective, always adding it might have seemed 
> like the simplest approach.
> 
> However, from an end-user perspective, it's not logical for `status` to 
> show nothing while `add` has an effect. 

I'm quite sympathetic to this view, I think you should explain this in the commit message where you change the behavior and see what others think.

> A more intuitive workflow would 
> align with how ignored files are handled even though it is already tracked.

As I said before do not think conflating ignoring changes to tracked files with ignoring files is a good idea. The two are fundamentally different because ignored files are not tracked. I would suggest adding a new option such as "--include-ignored-submodules" instead of piggybacking on "--force". Using a different option also means that user's will not accidentally stage ignored files when they're trying to stage a submodule whose changes are normally ignored.

> My patch implements what I believe should have been in the first place. 
> My implementation still needs the `overwrite=1` set in order to get the 
> diff files list so I can 'operate' on it and make the `--force` logic 
> like the ignore files.

Oh, you're right, if we want to print a warning we will need to keep overriding the submodule config.

Hopefully someone with more experience of submodules will be able to review the code soon.

Thanks
Phillip
Previous: Claus SchneiderNext: Claus Schneider
Message 42 of 43 in “git-add : Respect submodule ignore=all and only add changes with --force”
  1. 0/5 git-add : Respect submodule ignore=all and only add changes with --forceClaus Schneider via GitGitGadget, Oct 18, 2025
  2. 1/5 read-cache: update add_files_to_cache to take param ignored_too(--force)Claus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  3. 2/5 read-cache: let read-cache respect submodule ignore=all and --forceClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  4. 3/5 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenarioClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  5. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  6. 5/5 Documentation: update add --force and submodule ignore=all configClaus Schneider(Eficode) via GitGitGadget, Oct 18, 2025
  7. Phillip WoodOct 19, 2025
  8. 0/5 git-add : Respect submodule ignore=all and only add changes with --forceClaus Schneider via GitGitGadget, Nov 13, 2025
  9. 1/5 read-cache: update add_files_to_cache take param include_ignored_submodulesClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  10. Junio C HamanoNov 13, 2025
  11. 2/5 read-cache: add/read-cache respect submodule ignore=allClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  12. 3/5 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenarioClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  13. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  14. 5/5 Documentation: add --include_ignored_submodules + ignore=all configClaus Schneider(Eficode) via GitGitGadget, Nov 13, 2025
  15. Junio C HamanoNov 13, 2025
  16. Claus SchneiderNov 14, 2025
  17. Claus SchneiderFeb 5, 2026
  18. Junio C HamanoFeb 5, 2026
  19. 0/5 git-add: Skip submodules with ignore=all unless --force and explicit path usedClaus Schneider via GitGitGadget, Jan 14, 2026
  20. 1/5 read-cache: update add_files_to_cache take param ignored_tooClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  21. 2/5 read-cache: submodule add need --force given ignore=all configurationClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  22. Kristoffer HaugsbakkJan 15, 2026
  23. Claus SchneiderJan 16, 2026
  24. 3/5 tests: t2206-add-submodule-ignored: ignore=all and add --force testsClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  25. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  26. 5/5 Documentation: update add --force option + ignore=all configClaus Schneider(Eficode) via GitGitGadget, Jan 14, 2026
  27. Ben KnobleJan 14, 2026
  28. Claus SchneiderJan 16, 2026
  29. 0/5 git-add: Skip submodules with ignore=all unless --force and explicit path usedClaus Schneider via GitGitGadget, Feb 6, 2026
  30. 1/5 read-cache: update add_files_to_cache take param ignored_tooClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  31. Junio C HamanoFeb 9, 2026
  32. Junio C HamanoFeb 9, 2026
  33. 2/5 read-cache: submodule add need --force given ignore=all configurationClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  34. 3/5 tests: t2206-add-submodule-ignored: ignore=all and add --force testsClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  35. 4/5 tests: fix existing tests when add an ignore=all submoduleClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  36. 5/5 Documentation: update add --force option + ignore=all configClaus Schneider(Eficode) via GitGitGadget, Feb 6, 2026
  37. Kristoffer HaugsbakkMar 4, 2026
  38. Claus SchneiderMar 10, 2026
  39. Claus SchneiderMar 10, 2026
  40. Junio C HamanoFeb 20, 2026
  41. Claus SchneiderOct 20, 2025
  42. Phillip WoodOct 24, 2025
  43. Claus SchneiderNov 13, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.