{"thread":{"id":"64349","subject":"[PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force","startedAt":"2025-10-18T20:07:21Z","lastAt":"2026-03-10T21:10:26Z","messageCount":43,"participants":["Claus Schneider via GitGitGadget","Claus Schneider(Eficode) via GitGitGadget","Phillip Wood","Claus Schneider","Junio C Hamano","Ben Knoble","Kristoffer Haugsbakk"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"529133","messageId":"pull.1987.git.1760818039.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":null,"subject":"[PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Claus Schneider via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-18T20:07:14Z","receivedAt":"2025-10-18T20:07:21Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"The feature of configuring a submodule to \"ignore=all\" is nicely respected\nin commands \"status\" and \"diff\". However the \"add\" command does not respect\nthe configuration the same way. The behavior is problematic for the logic\nbetween status/diff and add. Secondly it makes it problematic to track\nbranches in the submodule configuration as developers unintentionally keeps\nadd submodule updates and get conflicts for no intentional reason. Both adds\nunnecessary friction to the usage of submodules.\n\nThe patches implement the same logical behavior for ignore=all submodules as\nregular ignored files. The status now does not show any diff - nor will the\nadd command update the reference submodule reference. If you add the\nsubmodule path which is ignore=all then you are presented with a message\nthat you need to use the --force option. The branch=, ignore=all (and\nupdate=none) now works great with update --remote, but developers does not\nhave to consider changes in the updates of the submodule sha1. The\nimplementation removes a friction of working with submodules and can be used\nlike the repo tool with branches configured. The submodule status report\ncould be used for build/release documentation for reproduction of a setup.\n\nA few tests used the adding of submodules without --force, hence they have\nbeen updated to use the --force option.\n\nClaus Schneider(Eficode) (5):\n  read-cache: update add_files_to_cache to take param\n    ignored_too(--force)\n  read-cache: let read-cache respect submodule ignore=all and --force\n  tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n    scenario\n  tests: fix existing tests when add an ignore=all submodule\n  Documentation: update add --force and submodule ignore=all config\n\n Documentation/git-add.adoc       |   4 +-\n Documentation/gitmodules.adoc    |   5 +-\n builtin/add.c                    |   2 +-\n builtin/checkout.c               |   2 +-\n builtin/commit.c                 |   2 +-\n read-cache-ll.h                  |   2 +-\n read-cache.c                     |  54 ++++++++++++-\n t/lib-submodule-update.sh        |   6 +-\n t/meson.build                    |   1 +\n t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n t/t7508-status.sh                |   2 +-\n 11 files changed, 202 insertions(+), 12 deletions(-)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\n\nbase-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1987\n-- \ngitgitgadget\n"},{"id":"529134","messageId":"d98cca698ddb376831c0657eab2c488f9e7585bc.1760818039.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"[PATCH 1/5] read-cache: update add_files_to_cache to take param ignored_too(--force)","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-18T20:07:15Z","receivedAt":"2025-10-18T20:07:22Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe ignored_too parameter is added to the function add_files_to_cache for\nusage of explicit updating the index for the updated submodule using the\nexplicit patchspec to the submodule.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n builtin/add.c      | 2 +-\n builtin/checkout.c | 2 +-\n builtin/commit.c   | 2 +-\n read-cache-ll.h    | 2 +-\n read-cache.c       | 8 +++++++-\n 5 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0235854f80..cd1116e70a 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -582,7 +582,7 @@ int cmd_add(int argc,\n \telse\n \t\texit_status |= add_files_to_cache(repo, prefix,\n \t\t\t\t\t\t  &pathspec, ps_matched,\n-\t\t\t\t\t\t  include_sparse, flags);\n+\t\t\t\t\t\t  include_sparse, flags, ignored_too);\n \n \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n \t    report_path_error(ps_matched, &pathspec))\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex f9453473fe..b2a404051d 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -899,7 +899,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t\t */\n \n \t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n-\t\t\t\t\t   0);\n+\t\t\t\t\t   0, 0 );\n \t\t\tinit_ui_merge_options(&o, the_repository);\n \t\t\to.verbosity = 0;\n \t\t\twork = write_in_core_index_as_tree(the_repository);\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex b5b9608813..5bf7ae5fc1 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -455,7 +455,7 @@ static const char *prepare_index(const char **argv, const char *prefix,\n \t\trepo_hold_locked_index(the_repository, &index_lock,\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\tadd_files_to_cache(the_repository, also ? prefix : NULL,\n-\t\t\t\t   &pathspec, ps_matched, 0, 0);\n+\t\t\t\t   &pathspec, ps_matched, 0, 0, 0 );\n \t\tif (!all && report_path_error(ps_matched, &pathspec))\n \t\t\texit(128);\n \ndiff --git a/read-cache-ll.h b/read-cache-ll.h\nindex 71b49d9af4..2c8b4b21b1 100644\n--- a/read-cache-ll.h\n+++ b/read-cache-ll.h\n@@ -481,7 +481,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags);\n+\t\t       int include_sparse, int flags, int ignored_too );\n \n void overlay_tree_on_index(struct index_state *istate,\n \t\t\t   const char *tree_name, const char *prefix);\ndiff --git a/read-cache.c b/read-cache.c\nindex 06ad74db22..56a3ef424c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3880,9 +3880,12 @@ void overlay_tree_on_index(struct index_state *istate,\n \n struct update_callback_data {\n \tstruct index_state *index;\n+\tstruct repository *repo;\n+\tstruct pathspec *pathspec;\n \tint include_sparse;\n \tint flags;\n \tint add_errors;\n+\tint ignored_too;\n };\n \n static int fix_unmerged_status(struct diff_filepair *p,\n@@ -3945,7 +3948,7 @@ static void update_callback(struct diff_queue_struct *q,\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags)\n+\t\t       int include_sparse, int flags, int ignored_too )\n {\n \tstruct update_callback_data data;\n \tstruct rev_info rev;\n@@ -3954,6 +3957,9 @@ int add_files_to_cache(struct repository *repo, const char *prefix,\n \tdata.index = repo->index;\n \tdata.include_sparse = include_sparse;\n \tdata.flags = flags;\n+\tdata.repo = repo;\n+\tdata.ignored_too = ignored_too;\n+\tdata.pathspec = (struct pathspec *)pathspec;\n \n \trepo_init_revisions(repo, &rev, prefix);\n \tsetup_revisions(0, NULL, &rev, NULL);\n-- \ngitgitgadget\n\n"},{"id":"529135","messageId":"d1b02617e643a32cecc81131cb411b180d6339a4.1760818039.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"[PATCH 2/5] read-cache: let read-cache respect submodule ignore=all and --force","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-18T20:07:16Z","receivedAt":"2025-10-18T20:07:24Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nGiven the submdule configuration is ignore=all then only update the\nsubmdule if the --force option is given and the submodule is explicit\ngiven in the pathspec.\n\nA message is printed (like ignored files) guiding the user to use the\n--force flag if the user has explicitely want to update the submodule\nreference.\n\nThe reason for the change is support submodule branch tracking or\nsimilar and git status state nothing and git add should not add either.\nThe workflow is more logic and similar to regular ignored files even\nthe submodule is already tracked.\n\nThe change opens up a lot of possibilities for submodules to be used\nmore freely and a like the repo tool. A submodule can be added for many\nmore reason and loosely coupled dependencies to the super repo which often\ngives the friction of handle the explicit commits and updates without\nthe need for tracking the submodule sha1 by sha1.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n read-cache.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 45 insertions(+), 1 deletion(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 56a3ef424c..3e87d03518 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -48,6 +48,8 @@\n #include \"csum-file.h\"\n #include \"promisor-remote.h\"\n #include \"hook.h\"\n+#include \"submodule.h\"\n+#include \"submodule-config.h\"\n \n /* Mask for the name length in ce_flags in the on-disk index */\n \n@@ -3927,13 +3929,55 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tdefault:\n \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n \t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n+\t\t\tstruct stat st;\n+\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n+\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n+\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n+\t\t\t\t\tint pathspec_matches = 0;\n+\t\t\t\t\tchar *norm_pathspec = NULL;\n+\t\t\t\t\tint ps_i;\n+\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n+\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n+\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n+\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n+\t\t\t\t\tif (data->pathspec) {\n+\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n+\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n+\t\t\t\t\t\t\tif (!m)\n+\t\t\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n+\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n+\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n+\t\t\t\t\t\t\t\tpathspec_matches = 1;\n+\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t\t\t\t\t\t\tbreak;\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t\tif (pathspec_matches) {\n+\t\t\t\t\t\tif (data->ignored_too && data->ignored_too > 0) {\n+\t\t\t\t\t\t\ttrace_printf(\"Forcing add of submodule ignored=all due to --force: %s\\n\", path);\n+\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n+\t\t\t\t\t\t\tprintf(_(\"Use -f if you really want to add them.\") );\n+\t\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n+\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n+\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n \t\t\t\t\tdie(_(\"updating files failed\"));\n \t\t\t\tdata->add_errors++;\n \t\t\t}\n \t\t\tbreak;\n+\t\t}\n \t\tcase DIFF_STATUS_DELETED:\n \t\t\tif (data->flags & ADD_CACHE_IGNORE_REMOVAL)\n \t\t\t\tbreak;\n-- \ngitgitgadget\n\n"},{"id":"529136","messageId":"8f3d5f7ec12d788eec99b962fed1c8d62e17c148.1760818039.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"[PATCH 3/5] tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-18T20:07:17Z","receivedAt":"2025-10-18T20:07:25Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe tests verify that the submodule behavior is intact and updating the\nconfig with ignore=all also behaves as intended with configuration in\n.gitmodules and configuration given on the command line.\n\nTestfile is added to meson.build for execution.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/meson.build                    |   1 +\n t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n 2 files changed, 135 insertions(+)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\ndiff --git a/t/meson.build b/t/meson.build\nindex bbeba1a8d5..1a6fb7edb2 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -281,6 +281,7 @@ integration_tests = [\n   't2203-add-intent.sh',\n   't2204-add-ignored.sh',\n   't2205-add-worktree-config.sh',\n+  't2206-add-submodule-ignored.sh',\n   't2300-cd-to-toplevel.sh',\n   't2400-worktree-add.sh',\n   't2401-worktree-prune.sh',\ndiff --git a/t/t2206-add-submodule-ignored.sh b/t/t2206-add-submodule-ignored.sh\nnew file mode 100755\nindex 0000000000..77f7b0ebbc\n--- /dev/null\n+++ b/t/t2206-add-submodule-ignored.sh\n@@ -0,0 +1,134 @@\n+#!/bin/sh\n+# shellcheck disable=SC2016\n+\n+# shellcheck disable=SC2034\n+test_description='git add respects submodule ignore=all and explicit pathspec'\n+\n+# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n+# dealing with submodules that have the ignore=all setting in\n+# .gitmodules. It ensures that changes in such submodules are\n+# ignored by default, but can be staged with \"git add --force\".\n+\n+# shellcheck disable=SC1091\n+. ./test-lib.sh\n+\n+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n+base_path=$(pwd -P)\n+\n+#1\n+test_expect_success 'setup: create origin repos'  '\n+\tcd \"${base_path}\" &&\n+\tgit config --global protocol.file.allow always &&\n+\tgit init sub &&\n+\t\tpwd &&\n+\t\tcd sub &&\n+\t\ttest_commit sub_file1 &&\n+\t\tgit tag v1.0 &&\n+\t\ttest_commit sub_file2 &&\n+\t\tgit tag v2.0 &&\n+\t\ttest_commit sub_file3 &&\n+\t\tgit tag v3.0 &&\n+\tcd \"${base_path}\" &&\n+\tgit init main &&\n+\t\tcd main &&\n+\t\ttest_commit first &&\n+\tcd \"${base_path}\"\n+'\n+#2\n+# add submodule with default config (ignore=none) and\n+# check log that is contains a path entry for the submodule 'sub'\n+# change the commit in the submodule and check that 'git status' shows it as modified\n+test_expect_success 'main: add submodule with default config'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit submodule add ../sub &&\n+\tgit commit -m \"add submodule\" &&\n+\tgit log --oneline --name-only | grep \"^sub$\" &&\n+\tgit -C sub reset --hard v2.0 &&\n+\tgit status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+#3\n+# change the submodule config to ignore=all and check that status and log do not show changes\n+test_expect_success 'main: submodule config ignore=all'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit config -f .gitmodules submodule.sub.ignore all &&\n+\tGIT_TRACE=1 git add . &&\n+\tgit commit -m \"update submodule config sub.ignore all\" &&\n+\t! git status --porcelain | grep \"^.*$\" &&\n+\t! git log --oneline --name-only | grep \"^sub$\" &&\n+\techo\n+'\n+#4\n+# change the commit in the submodule and check that 'git status' does not show it as modified\n+# but 'git status --ignore-submodules=none' does show it as modified\n+test_expect_success 'sub: change to different sha1 and check status in main'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit -C sub reset --hard v1.0 &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit status --ignore-submodules=none --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#5\n+# check that normal 'git add' does not stage the change in the submodule\n+test_expect_success 'main: check normal add and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add . &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#6\n+# check that 'git add --force .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check --force add . and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add --force . &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#7\n+# check that 'git add .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check _add sub_ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add sub | grep \"Skipping submodule due to ignore=all: sub\" &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#8\n+# check that 'git add --force sub' does stage the change in the submodule\n+# check that 'git add --force ./sub/' does stage the change in the submodule\n+# and that 'git status --porcelain' does show it as modified\n+# commit it..\n+# check that 'git log --ignore-submodules=none' shows the submodule change\n+# in the log\n+test_expect_success 'main: check force add sub and ./sub/ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\techo \"Adding with --force should work: git add --force sub\" &&\n+\tGIT_TRACE=1 git add --force sub &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit restore --staged sub &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo \"Adding with --force should work: git add --force ./sub/\" &&\n+\tGIT_TRACE=1 git add --force ./sub/ &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit commit -m \"update submodule pointer\" &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit log --ignore-submodules=none --name-only --oneline | grep \"^sub$\" &&\n+\techo\n+'\n+\n+test_done\n+exit 0\n-- \ngitgitgadget\n\n"},{"id":"529137","messageId":"58563a7b9039ff75bc449fc781a95a286c11c2b4.1760818039.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"[PATCH 4/5] tests: fix existing tests when add an ignore=all submodule","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-18T20:07:18Z","receivedAt":"2025-10-18T20:07:26Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThere are tests that rely on \"git add <submodule>\" also adds it. A --force\nis needed with this enhancement hence they are added accordingly in these\ntests.\n\nUpdated tests:\n- t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t7406-submodule-update.sh\n- t7508-status.sh\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/lib-submodule-update.sh | 6 +++---\n t/t7508-status.sh         | 2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 36f767cb74..f591de6120 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -95,14 +95,14 @@ create_lib_submodule_repo () {\n \t\t\tgit commit -m \"modified file2 and added file3\" &&\n \t\t\tgit push origin modifications\n \t\t) &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -m \"Modify sub1\" &&\n \n \t\tgit checkout -b add_nested_sub modify_sub1 &&\n \t\tgit -C sub1 checkout -b \"add_nested_sub\" &&\n \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n \t\tgit checkout -b modify_sub1_recursively &&\n \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n@@ -112,7 +112,7 @@ create_lib_submodule_repo () {\n \t\tgit -C sub1/sub2 commit -m \"make a change in nested sub\" &&\n \t\tgit -C sub1 add sub2 &&\n \t\tgit -C sub1 commit -m \"update nested sub\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n \t\tgit -C sub1 push origin modify_sub1_recursively &&\n \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex cdc1d6fcc7..7617be14e8 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1565,7 +1565,7 @@ test_expect_success 'git commit will commit a staged but ignored submodule' '\n \n test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n \tgit reset HEAD^ &&\n-\tgit add sm &&\n+\tgit add --force sm &&\n \tcat >expect << EOF &&\n On branch main\n Your branch and '\\''upstream'\\'' have diverged,\n-- \ngitgitgadget\n\n"},{"id":"529138","messageId":"416695f439032e027a322c752df3e4215b8d233b.1760818039.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"[PATCH 5/5] Documentation: update add --force and submodule ignore=all config","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-18T20:07:19Z","receivedAt":"2025-10-18T20:07:27Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\n- The add --force doc: append additionel info about the submodule\nfunctionality.\n- The submodule config ignore=all now need --force in order to update\n  the index.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n Documentation/git-add.adoc    | 4 +++-\n Documentation/gitmodules.adoc | 5 ++++-\n 2 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\nindex b7a735824d..2234b1e846 100644\n--- a/Documentation/git-add.adoc\n+++ b/Documentation/git-add.adoc\n@@ -77,7 +77,9 @@ in linkgit:gitglossary[7].\n \n `-f`::\n `--force`::\n-\tAllow adding otherwise ignored files.\n+\tAllow adding otherwise ignored files. The option is also used\n+\twhen updating submodules and `submodule.<name>.ignore=all`\n+\tis set. The `path` to the submodule must be explicitly specified.\n \n `--sparse`::\n \tAllow updating index entries outside of the sparse-checkout cone.\ndiff --git a/Documentation/gitmodules.adoc b/Documentation/gitmodules.adoc\nindex d9bec8b187..3aa71170ee 100644\n--- a/Documentation/gitmodules.adoc\n+++ b/Documentation/gitmodules.adoc\n@@ -70,7 +70,10 @@ submodule.<name>.ignore::\n --\n \tall;; The submodule will never be considered modified (but will\n \t    nonetheless show up in the output of status and commit when it has\n-\t    been staged).\n+\t    been staged). Add `(new commits)` can be overruled using the\n+\t    `git add --force <submodule.path>` similar to ignored files. The setting has effect\n+\t    for `status`, `update-index`, `diff` and `log`(due to underlaying\n+\t    `diff`)\n \n \tdirty;; All changes to the submodule's work tree will be ignored, only\n \t    committed differences between the `HEAD` of the submodule and its\n-- \ngitgitgadget\n"},{"id":"529146","messageId":"2688a523-e324-41bb-858f-b32040e1e909@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-10-19T15:34:19Z","receivedAt":"2025-10-19T15:34:24Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Claus\n\n[I've adjusted the CC list slightly]\n\nOn 18/10/2025 21:07, Claus Schneider via GitGitGadget wrote:\n> The feature of configuring a submodule to \"ignore=all\" is nicely respected\n> in commands \"status\" and \"diff\". However the \"add\" command does not respect\n> the configuration the same way.\n\nI was curious why, when \"git add\" uses the same machinery as \"git diff\" \nto figure out which paths need updating, it behaves differently. It \nturns out that add_files_to_cache() contains\n\n\trev.diffopt.flags.override_submodule_config = 1;\n\nwhich makes \"git add\" ignore \"submodule.<name>.ignore\". Tracing the \nhistory of this line, it originates from 5556808690e (add, reset: ensure \nsubmodules can be added or reset, 2017-07-25) which made a deliberate \nchoice for both \"git add\" and \"git reset\" not to behave like \"git diff\". \nIf we're going to change the behavior then it would be helpful to \nexplain how this patch series ameliorates the concerns that lead to that \ncommit and why it is sensible to change the behavior of \"git add\" but \nnot \"git reset\". It also suggests that a much simpler way of \nimplementing the change would be to delete that line.\n\nI'm not convinced that the approach of using \"--force\" is a good idea as \nit conflates ignoring changes to tracked paths (which is what \nsubmodule.<name>.ignore\" does) with ignoring untracked paths (which is \nwhat \".gitignore\" does). If we're happy to break existing uses that rely \non the current behavior then having a new option to override \nsubmodule.<name>.ignore strikes me as a better way forward. I don't have \nmuch experience of using submodules so I can't comment on whether \nchanging the behavior is a good idea or not.\n\nThanks\n\nPhillip\n\n\n  The behavior is problematic for the logic\n> between status/diff and add. Secondly it makes it problematic to track\n> branches in the submodule configuration as developers unintentionally keeps\n> add submodule updates and get conflicts for no intentional reason. Both adds\n> unnecessary friction to the usage of submodules.\n> \n> The patches implement the same logical behavior for ignore=all submodules as\n> regular ignored files. The status now does not show any diff - nor will the\n> add command update the reference submodule reference. If you add the\n> submodule path which is ignore=all then you are presented with a message\n> that you need to use the --force option. The branch=, ignore=all (and\n> update=none) now works great with update --remote, but developers does not\n> have to consider changes in the updates of the submodule sha1. The\n> implementation removes a friction of working with submodules and can be used\n> like the repo tool with branches configured. The submodule status report\n> could be used for build/release documentation for reproduction of a setup.\n> \n> A few tests used the adding of submodules without --force, hence they have\n> been updated to use the --force option.\n> \n> Claus Schneider(Eficode) (5):\n>    read-cache: update add_files_to_cache to take param\n>      ignored_too(--force)\n>    read-cache: let read-cache respect submodule ignore=all and --force\n>    tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n>      scenario\n>    tests: fix existing tests when add an ignore=all submodule\n>    Documentation: update add --force and submodule ignore=all config\n> \n>   Documentation/git-add.adoc       |   4 +-\n>   Documentation/gitmodules.adoc    |   5 +-\n>   builtin/add.c                    |   2 +-\n>   builtin/checkout.c               |   2 +-\n>   builtin/commit.c                 |   2 +-\n>   read-cache-ll.h                  |   2 +-\n>   read-cache.c                     |  54 ++++++++++++-\n>   t/lib-submodule-update.sh        |   6 +-\n>   t/meson.build                    |   1 +\n>   t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n>   t/t7508-status.sh                |   2 +-\n>   11 files changed, 202 insertions(+), 12 deletions(-)\n>   create mode 100755 t/t2206-add-submodule-ignored.sh\n> \n> \n> base-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/1987\n\n"},{"id":"529158","messageId":"CA+GP4boSRx-FrAppz5oWauPwUxRpLt5u372m1Q4b+JpeeOTUHQ@mail.gmail.com","threadId":"64349","inReplyTo":"CA+GP4bpu3SUycG35DU5+NSuiqtfYN9-R=7d01EFhexgGh4sRPg@mail.gmail.com","subject":"Re: [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2025-10-20T07:28:39Z","receivedAt":"2025-10-20T07:28:53Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Hi again ..\n\nI have read the documentation for submodule and reset. See from a\nnon-git-developer it is actually pretty hard to understand what\nhappens with regards to the \"reset\" command.\n\nThe only hint I can find which does not mean a lot to an ordinary user:\n- \"Defines under what circumstances \"git status\" and the diff family\nshow a submodule as modified\".\n- GPT-5 does not say anything regarding \"reset\", if asked a few levels\nof \"/explains\" regarding \"diff family\". I find the documentation\ninconclusive as an end-user.\n- Looking at the \"reset\" --help it does only talk about\n--[no-]recurse-submodules but not really what the ignore=all\n- I can find the override_submodule_config=1 in reset, commit, status,\nadd-interactive, read-cache.\n.. so I am a bit confused.\n\nFrom an end-user perspective I would expect this of \"all\":\n- (pre-action): \"status\" and \"diff-of-workspace/staging\". It should\nrespect ignore=all unless overridden or explicit specified\n- (action): \"add\" : It should respect ignore=all unless overridden or\nexplicit specified(--force)\n- (action): \"reset\", \"restore\" ..<etc>: It should respect ignore=all\nunless overridden or explicit specified and leave it to submodules\n--init / --remote\n- (action): \"clean\": It could be argued of the -x option should also\nact on submodules - but fair to leave it to submodules --init /\n--remote\n- (post-action) \"diff-of-history\", \"log\" (aka <ref1> <ref2> ) : It\nshould always tell what happened in history (git-graph) despite what\nthe current .gitmodules states regards to ignore=all\n\nIt could be a new option value should be added like \"always\" or\n\"logical\" respectively the above and then leave the \"all\" to the\ncurrent behavior.\n\nBest regards\nClaus\n\n\n\nOn Sun, Oct 19, 2025 at 11:55 PM Claus Schneider\n<claus.schneider@eficode.com> wrote:\n>\n> Hi Philip ..\n>\n> 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.\n>\n> 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.\n>\n> However, from an end-user perspective, it's not logical for `status` to show nothing while `add` has an effect. A more intuitive workflow would align with how ignored files are handled even though it is already tracked.\n>\n> 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.\n>\n> Best regards\n> Claus\n>\n> On Sun, Oct 19, 2025, 17:34 Phillip Wood <phillip.wood123@gmail.com> wrote:\n>>\n>> Hi Claus\n>>\n>> [I've adjusted the CC list slightly]\n>>\n>> On 18/10/2025 21:07, Claus Schneider via GitGitGadget wrote:\n>> > The feature of configuring a submodule to \"ignore=all\" is nicely respected\n>> > in commands \"status\" and \"diff\". However the \"add\" command does not respect\n>> > the configuration the same way.\n>>\n>> I was curious why, when \"git add\" uses the same machinery as \"git diff\"\n>> to figure out which paths need updating, it behaves differently. It\n>> turns out that add_files_to_cache() contains\n>>\n>>         rev.diffopt.flags.override_submodule_config = 1;\n>>\n>> which makes \"git add\" ignore \"submodule.<name>.ignore\". Tracing the\n>> history of this line, it originates from 5556808690e (add, reset: ensure\n>> submodules can be added or reset, 2017-07-25) which made a deliberate\n>> choice for both \"git add\" and \"git reset\" not to behave like \"git diff\".\n>> If we're going to change the behavior then it would be helpful to\n>> explain how this patch series ameliorates the concerns that lead to that\n>> commit and why it is sensible to change the behavior of \"git add\" but\n>> not \"git reset\". It also suggests that a much simpler way of\n>> implementing the change would be to delete that line.\n>>\n>> I'm not convinced that the approach of using \"--force\" is a good idea as\n>> it conflates ignoring changes to tracked paths (which is what\n>> submodule.<name>.ignore\" does) with ignoring untracked paths (which is\n>> what \".gitignore\" does). If we're happy to break existing uses that rely\n>> on the current behavior then having a new option to override\n>> submodule.<name>.ignore strikes me as a better way forward. I don't have\n>> much experience of using submodules so I can't comment on whether\n>> changing the behavior is a good idea or not.\n>>\n>> Thanks\n>>\n>> Phillip\n>>\n>>\n>>   The behavior is problematic for the logic\n>> > between status/diff and add. Secondly it makes it problematic to track\n>> > branches in the submodule configuration as developers unintentionally keeps\n>> > add submodule updates and get conflicts for no intentional reason. Both adds\n>> > unnecessary friction to the usage of submodules.\n>> >\n>> > The patches implement the same logical behavior for ignore=all submodules as\n>> > regular ignored files. The status now does not show any diff - nor will the\n>> > add command update the reference submodule reference. If you add the\n>> > submodule path which is ignore=all then you are presented with a message\n>> > that you need to use the --force option. The branch=, ignore=all (and\n>> > update=none) now works great with update --remote, but developers does not\n>> > have to consider changes in the updates of the submodule sha1. The\n>> > implementation removes a friction of working with submodules and can be used\n>> > like the repo tool with branches configured. The submodule status report\n>> > could be used for build/release documentation for reproduction of a setup.\n>> >\n>> > A few tests used the adding of submodules without --force, hence they have\n>> > been updated to use the --force option.\n>> >\n>> > Claus Schneider(Eficode) (5):\n>> >    read-cache: update add_files_to_cache to take param\n>> >      ignored_too(--force)\n>> >    read-cache: let read-cache respect submodule ignore=all and --force\n>> >    tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n>> >      scenario\n>> >    tests: fix existing tests when add an ignore=all submodule\n>> >    Documentation: update add --force and submodule ignore=all config\n>> >\n>> >   Documentation/git-add.adoc       |   4 +-\n>> >   Documentation/gitmodules.adoc    |   5 +-\n>> >   builtin/add.c                    |   2 +-\n>> >   builtin/checkout.c               |   2 +-\n>> >   builtin/commit.c                 |   2 +-\n>> >   read-cache-ll.h                  |   2 +-\n>> >   read-cache.c                     |  54 ++++++++++++-\n>> >   t/lib-submodule-update.sh        |   6 +-\n>> >   t/meson.build                    |   1 +\n>> >   t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n>> >   t/t7508-status.sh                |   2 +-\n>> >   11 files changed, 202 insertions(+), 12 deletions(-)\n>> >   create mode 100755 t/t2206-add-submodule-ignored.sh\n>> >\n>> >\n>> > base-commit: c44beea485f0f2feaf460e2ac87fdd5608d63cf0\n>> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v1\n>> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v1\n>> > Pull-Request: https://github.com/gitgitgadget/git/pull/1987\n>>\n"},{"id":"529604","messageId":"63d07c3c-ac4b-4ef9-ad90-d79f00cc7ca9@gmail.com","threadId":"64349","inReplyTo":"CA+GP4bqb775U5oBbLZg1dou+THJOjTbFN+2Pq1cBPqq1SgbxHw@mail.gmail.com","subject":"Re: [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-10-24T13:55:46Z","receivedAt":"2025-10-24T13:55:49Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Claus\n\nOn 19/10/2025 22:39, Claus Schneider wrote:\n> On Sun, Oct 19, 2025, 17:34 Phillip Wood <phillip.wood123@gmail.com \n> <mailto:phillip.wood123@gmail.com>> wrote:\n> \n>> I was curious why, when \"git add\" uses the same machinery as \"git diff\"\n>> to figure out which paths need updating, it behaves differently. It\n>> turns out that add_files_to_cache() contains\n>> \n>>           rev.diffopt.flags.override_submodule_config = 1;\n>> \n>> which makes \"git add\" ignore \"submodule.<name>.ignore\". Tracing the\n>> history of this line, it originates from 5556808690e (add, reset: ensure\n>> submodules can be added or reset, 2017-07-25) which made a deliberate\n>> choice for both \"git add\" and \"git reset\" not to behave like \"git diff\".\n\n> Thank you for your feedback and for investigating this. I was not aware > of the setting that causes `add` and `reset` to override submodule \n> configuration, and I will need to look into `reset` further.\n\nYou should mention the commit that added the current behavior and the\nreason it was added in the commit message where you change the behavior.\n\n> I understand the problematic aspect of not being able to add an update \n> of a submodule reference, which likely led to the overwrite setting. \n> From a Git developer's perspective, always adding it might have seemed \n> like the simplest approach.\n> \n> However, from an end-user perspective, it's not logical for `status` to \n> show nothing while `add` has an effect. \n\nI'm quite sympathetic to this view, I think you should explain this in the\ncommit message where you change the behavior and see what others think.\n\n> A more intuitive workflow would \n> align with how ignored files are handled even though it is already tracked.\n\nAs I said before do not think conflating ignoring changes to tracked files\nwith ignoring files is a good idea. The two are fundamentally different\nbecause ignored files are not tracked. I would suggest adding a new option\nsuch as \"--include-ignored-submodules\" instead of piggybacking on \"--force\".\nUsing a different option also means that user's will not accidentally stage\nignored files when they're trying to stage a submodule whose changes are\nnormally ignored.\n\n> My patch implements what I believe should have been in the first place. \n> My implementation still needs the `overwrite=1` set in order to get the \n> diff files list so I can 'operate' on it and make the `--force` logic \n> like the ignore files.\n\nOh, you're right, if we want to print a warning we will need to keep\noverriding the submodule config.\n\nHopefully someone with more experience of submodules will be able to review\nthe code soon.\n\nThanks\n\nPhillip\n\n"},{"id":"530644","messageId":"CA+GP4boOQ0YfKHOup4qxA2hiwA63d=61LF7jdD-=bHGTw1CfxA@mail.gmail.com","threadId":"64349","inReplyTo":"63d07c3c-ac4b-4ef9-ad90-d79f00cc7ca9@gmail.com","subject":"Re: [PATCH 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2025-11-13T12:51:53Z","receivedAt":"2025-11-13T12:52:07Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Thanks for the feedback and suggestions.\n\nI have now implemented the --include-ignored-submodules option instead\nof --force.\nI have also extended the commit messages with more reasoning.\n\n? Is it best to have a single commit with everything or a set of\ncommit for each part of the solution\n\n? How do I update the patches with the modifications accordingly (\nfrom GitGadget PR with a new /submit ) ?\n\nThanks in advance\nClaus Schneider\n\nOn Fri, Oct 24, 2025 at 3:55 PM Phillip Wood <phillip.wood123@gmail.com> wrote:\n>\n> Hi Claus\n>\n> On 19/10/2025 22:39, Claus Schneider wrote:\n> > On Sun, Oct 19, 2025, 17:34 Phillip Wood <phillip.wood123@gmail.com\n> > <mailto:phillip.wood123@gmail.com>> wrote:\n> >\n> >> I was curious why, when \"git add\" uses the same machinery as \"git diff\"\n> >> to figure out which paths need updating, it behaves differently. It\n> >> turns out that add_files_to_cache() contains\n> >>\n> >>           rev.diffopt.flags.override_submodule_config = 1;\n> >>\n> >> which makes \"git add\" ignore \"submodule.<name>.ignore\". Tracing the\n> >> history of this line, it originates from 5556808690e (add, reset: ensure\n> >> submodules can be added or reset, 2017-07-25) which made a deliberate\n> >> choice for both \"git add\" and \"git reset\" not to behave like \"git diff\".\n>\n> > Thank you for your feedback and for investigating this. I was not aware > of the setting that causes `add` and `reset` to override submodule\n> > configuration, and I will need to look into `reset` further.\n>\n> You should mention the commit that added the current behavior and the\n> reason it was added in the commit message where you change the behavior.\n>\n> > I understand the problematic aspect of not being able to add an update\n> > of a submodule reference, which likely led to the overwrite setting.\n> > From a Git developer's perspective, always adding it might have seemed\n> > like the simplest approach.\n> >\n> > However, from an end-user perspective, it's not logical for `status` to\n> > show nothing while `add` has an effect.\n>\n> I'm quite sympathetic to this view, I think you should explain this in the\n> commit message where you change the behavior and see what others think.\n>\n> > A more intuitive workflow would\n> > align with how ignored files are handled even though it is already tracked.\n>\n> As I said before do not think conflating ignoring changes to tracked files\n> with ignoring files is a good idea. The two are fundamentally different\n> because ignored files are not tracked. I would suggest adding a new option\n> such as \"--include-ignored-submodules\" instead of piggybacking on \"--force\".\n> Using a different option also means that user's will not accidentally stage\n> ignored files when they're trying to stage a submodule whose changes are\n> normally ignored.\n>\n> > My patch implements what I believe should have been in the first place.\n> > My implementation still needs the `overwrite=1` set in order to get the\n> > diff files list so I can 'operate' on it and make the `--force` logic\n> > like the ignore files.\n>\n> Oh, you're right, if we want to print a warning we will need to keep\n> overriding the submodule config.\n>\n> Hopefully someone with more experience of submodules will be able to review\n> the code soon.\n>\n> Thanks\n>\n> Phillip\n"},{"id":"530653","messageId":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.git.1760818039.gitgitgadget@gmail.com","subject":"[PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Claus Schneider via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-13T18:10:28Z","receivedAt":"2025-11-13T18:10:35Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"The feature of configuring a submodule to \"ignore=all\" is nicely respected\nin commands \"status\" and \"diff\". However the \"add\" command does not respect\nthe configuration the same way. The behavior is problematic for the logic\nbetween status/diff and add. Secondly it makes it problematic to track\nbranches in the submodule configuration as developers unintentionally keeps\nadd submodule updates and get conflicts for no intentional reason. Both adds\nunnecessary friction to the usage of submodules.\n\nThe patches implement the same logical behavior for ignore=all submodules as\nregular ignored files. The status now does not show any diff - nor will the\nadd command update the reference submodule reference. If you add the\nsubmodule path which is ignore=all then you are presented with a message\nthat you need to use the --force option. The branch=, ignore=all (and\nupdate=none) now works great with update --remote, but developers does not\nhave to consider changes in the updates of the submodule sha1. The\nimplementation removes a friction of working with submodules and can be used\nlike the repo tool with branches configured. The submodule status report\ncould be used for build/release documentation for reproduction of a setup.\n\nA few tests used the adding of submodules without --force, hence they have\nbeen updated to use the --force option.\n\nClaus Schneider(Eficode) (5):\n  read-cache: update add_files_to_cache take param\n    include_ignored_submodules\n  read-cache: add/read-cache respect submodule ignore=all\n  tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n    scenario\n  tests: fix existing tests when add an ignore=all submodule\n  Documentation: add --include_ignored_submodules + ignore=all config\n\n .devcontainer/Dockerfile            |  70 +++++++++++++++\n .devcontainer/Dockerfile.standalone |  76 ++++++++++++++++\n .devcontainer/devcontainer.json     |  25 ++++++\n Documentation/config/submodule.adoc |  13 +--\n Documentation/git-add.adoc          |   5 ++\n Documentation/gitmodules.adoc       |   5 +-\n builtin/add.c                       |   4 +-\n builtin/checkout.c                  |   2 +-\n builtin/commit.c                    |   2 +-\n read-cache-ll.h                     |   2 +-\n read-cache.c                        |  54 ++++++++++-\n t/lib-submodule-update.sh           |   6 +-\n t/meson.build                       |   1 +\n t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++\n t/t7508-status.sh                   |   2 +-\n 15 files changed, 384 insertions(+), 17 deletions(-)\n create mode 100644 .devcontainer/Dockerfile\n create mode 100644 .devcontainer/Dockerfile.standalone\n create mode 100644 .devcontainer/devcontainer.json\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\n\nbase-commit: 81f86aacc4eb74cdb9c2c8082d36d2070c666045\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/1987\n\nRange-diff vs v1:\n\n 1:  d98cca698d ! 1:  5796009122 read-cache: update add_files_to_cache to take param ignored_too(--force)\n     @@ Metadata\n      Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## Commit message ##\n     -    read-cache: update add_files_to_cache to take param ignored_too(--force)\n     +    read-cache: update add_files_to_cache take param include_ignored_submodules\n      \n     -    The ignored_too parameter is added to the function add_files_to_cache for\n     -    usage of explicit updating the index for the updated submodule using the\n     -    explicit patchspec to the submodule.\n     +    The include_ignored_submodules parameter is added to the function\n     +    add_files_to_cache for usage of explicit updating the index for the updated\n     +    submodule using the explicit patchspec to the submodule.\n      \n          Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## builtin/add.c ##\n     +@@ builtin/add.c: N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n     + static int verbose, show_only, ignored_too, refresh_only;\n     + static int ignore_add_errors, intent_to_add, ignore_missing;\n     + static int warn_on_embedded_repo = 1;\n     ++static int include_ignored_submodules;\n     + \n     + #define ADDREMOVE_DEFAULT 1\n     + static int addremove = ADDREMOVE_DEFAULT;\n     +@@ builtin/add.c: static struct option builtin_add_options[] = {\n     + \tOPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n     + \tOPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n     + \tOPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n     ++    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n     + \tOPT_STRING(0, \"chmod\", &chmod_arg, \"(+|-)x\",\n     + \t\t   N_(\"override the executable bit of the listed files\")),\n     + \tOPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n      @@ builtin/add.c: int cmd_add(int argc,\n       \telse\n       \t\texit_status |= add_files_to_cache(repo, prefix,\n       \t\t\t\t\t\t  &pathspec, ps_matched,\n      -\t\t\t\t\t\t  include_sparse, flags);\n     -+\t\t\t\t\t\t  include_sparse, flags, ignored_too);\n     ++\t\t\t\t\t\t  include_sparse, flags, include_ignored_submodules);\n       \n       \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n       \t    report_path_error(ps_matched, &pathspec))\n     @@ read-cache.c: void overlay_tree_on_index(struct index_state *istate,\n       \tint include_sparse;\n       \tint flags;\n       \tint add_errors;\n     -+\tint ignored_too;\n     ++\tint include_ignored_submodules;\n       };\n       \n       static int fix_unmerged_status(struct diff_filepair *p,\n      @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     + \t\tdefault:\n     + \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n     + \t\tcase DIFF_STATUS_MODIFIED:\n     +-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n     ++\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n     ++\t\t\tstruct stat st;\n     ++\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n     ++\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n     ++\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n     ++\t\t\t\t\tint pathspec_matches = 0;\n     ++\t\t\t\t\tchar *norm_pathspec = NULL;\n     ++\t\t\t\t\tint ps_i;\n     ++\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n     ++\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n     ++\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n     ++\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n     ++\t\t\t\t\tif (data->pathspec) {\n     ++\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n     ++\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n     ++\t\t\t\t\t\t\tif (!m)\n     ++\t\t\t\t\t\t\t\tcontinue;\n     ++\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n     ++\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n     ++\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n     ++\t\t\t\t\t\t\t\tpathspec_matches = 1;\n     ++\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     ++\t\t\t\t\t\t\t\tbreak;\n     ++\t\t\t\t\t\t\t}\n     ++\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     ++\t\t\t\t\t\t}\n     ++\t\t\t\t\t}\n     ++\t\t\t\t\tif (pathspec_matches) {\n     ++\t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n     ++\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n     ++\t\t\t\t\t\t} else {\n     ++\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n     ++\t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n     ++\t\t\t\t\t\t\tcontinue;\n     ++\t\t\t\t\t\t}\n     ++\t\t\t\t\t} else {\n     ++\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n     ++\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n     ++\t\t\t\t\t\tcontinue;\n     ++\t\t\t\t\t}\n     ++\t\t\t\t}\n     ++\t\t\t}\n     + \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n     + \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n     + \t\t\t\t\tdie(_(\"updating files failed\"));\n     +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n       \n       int add_files_to_cache(struct repository *repo, const char *prefix,\n       \t\t       const struct pathspec *pathspec, char *ps_matched,\n      -\t\t       int include_sparse, int flags)\n     -+\t\t       int include_sparse, int flags, int ignored_too )\n     ++\t\t       int include_sparse, int flags, int include_ignored_submodules )\n       {\n       \tstruct update_callback_data data;\n       \tstruct rev_info rev;\n     @@ read-cache.c: int add_files_to_cache(struct repository *repo, const char *prefix\n       \tdata.include_sparse = include_sparse;\n       \tdata.flags = flags;\n      +\tdata.repo = repo;\n     -+\tdata.ignored_too = ignored_too;\n     ++\tdata.include_ignored_submodules = include_ignored_submodules;\n      +\tdata.pathspec = (struct pathspec *)pathspec;\n       \n       \trepo_init_revisions(repo, &rev, prefix);\n 2:  d1b02617e6 ! 2:  9ec79b9a11 read-cache: let read-cache respect submodule ignore=all and --force\n     @@ Metadata\n      Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## Commit message ##\n     -    read-cache: let read-cache respect submodule ignore=all and --force\n     +    read-cache: add/read-cache respect submodule ignore=all\n      \n     -    Given the submdule configuration is ignore=all then only update the\n     -    submdule if the --force option is given and the submodule is explicit\n     -    given in the pathspec.\n     +    Submodules configured with ignore=all are now skipped during add operations\n     +    unless overridden by --include-ignored-submodules and the submodule path is\n     +    explicitly specified.\n      \n          A message is printed (like ignored files) guiding the user to use the\n     -    --force flag if the user has explicitely want to update the submodule\n     -    reference.\n     +    --include-ignored-submodules flag if the user has explicitely want to update\n     +    the submodule reference.\n      \n          The reason for the change is support submodule branch tracking or\n          similar and git status state nothing and git add should not add either.\n     @@ Commit message\n          the submodule is already tracked.\n      \n          The change opens up a lot of possibilities for submodules to be used\n     -    more freely and a like the repo tool. A submodule can be added for many\n     +    more freely and simular to the repo tool. A submodule can be added for many\n          more reason and loosely coupled dependencies to the super repo which often\n          gives the friction of handle the explicit commits and updates without\n          the need for tracking the submodule sha1 by sha1.\n     @@ read-cache.c\n       /* Mask for the name length in ce_flags in the on-disk index */\n       \n      @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     - \t\tdefault:\n     - \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n     - \t\tcase DIFF_STATUS_MODIFIED:\n     --\t\tcase DIFF_STATUS_TYPE_CHANGED:\n     -+\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n     -+\t\t\tstruct stat st;\n     -+\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n     -+\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n     -+\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n     -+\t\t\t\t\tint pathspec_matches = 0;\n     -+\t\t\t\t\tchar *norm_pathspec = NULL;\n     -+\t\t\t\t\tint ps_i;\n     -+\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n     -+\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n     -+\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n     -+\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n     -+\t\t\t\t\tif (data->pathspec) {\n     -+\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n     -+\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n     -+\t\t\t\t\t\t\tif (!m)\n     -+\t\t\t\t\t\t\t\tcontinue;\n     -+\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n     -+\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n     -+\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n     -+\t\t\t\t\t\t\t\tpathspec_matches = 1;\n     -+\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     -+\t\t\t\t\t\t\t\tbreak;\n     -+\t\t\t\t\t\t\t}\n     -+\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     -+\t\t\t\t\t\t}\n     -+\t\t\t\t\t}\n     -+\t\t\t\t\tif (pathspec_matches) {\n     -+\t\t\t\t\t\tif (data->ignored_too && data->ignored_too > 0) {\n     -+\t\t\t\t\t\t\ttrace_printf(\"Forcing add of submodule ignored=all due to --force: %s\\n\", path);\n     -+\t\t\t\t\t\t} else {\n     -+\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n     -+\t\t\t\t\t\t\tprintf(_(\"Use -f if you really want to add them.\") );\n     -+\t\t\t\t\t\t\tcontinue;\n     -+\t\t\t\t\t\t}\n     -+\t\t\t\t\t} else {\n     -+\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n     -+\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n     -+\t\t\t\t\t\tcontinue;\n     -+\t\t\t\t\t}\n     -+\t\t\t\t}\n     -+\t\t\t}\n     - \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n     - \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n     - \t\t\t\t\tdie(_(\"updating files failed\"));\n     + \t\t\t\t\t}\n     + \t\t\t\t\tif (pathspec_matches) {\n     + \t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n     +-\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n     ++\t\t\t\t\t\t\ttrace_printf(\"Add submodule due to --include_ignored_submodules: %s\\n\", path);\n     + \t\t\t\t\t\t} else {\n     + \t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n     + \t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n     +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     + \t\t\t\t\t\t}\n     + \t\t\t\t\t} else {\n     + \t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n     +-\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n     ++\t\t\t\t\t\ttrace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n     + \t\t\t\t\t\tcontinue;\n     + \t\t\t\t\t}\n     + \t\t\t\t}\n     +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n       \t\t\t\tdata->add_errors++;\n       \t\t\t}\n       \t\t\tbreak;\n 3:  8f3d5f7ec1 ! 3:  399a153b95 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario\n     @@ Commit message\n          config with ignore=all also behaves as intended with configuration in\n          .gitmodules and configuration given on the command line.\n      \n     -    Testfile is added to meson.build for execution.\n     +    The usage of --include_ignored_submodules is showcased and tested in the\n     +    test suite.\n     +\n     +    The test file is added to meson.build for execution.\n      \n          Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n      +# dealing with submodules that have the ignore=all setting in\n      +# .gitmodules. It ensures that changes in such submodules are\n     -+# ignored by default, but can be staged with \"git add --force\".\n     ++# ignored by default, but can be staged with \"git add --include-ignored-submodules\".\n      +\n      +# shellcheck disable=SC1091\n      +. ./test-lib.sh\n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +'\n      +\n      +#6\n     -+# check that 'git add --force .' does not stage the change in the submodule\n     ++# check that 'git add --include-ignored-submodules .' does not stage the change in the submodule\n      +# and that 'git status' does not show it as modified\n     -+test_expect_success 'main: check --force add . and status'  '\n     ++test_expect_success 'main: check --include-ignored-submodules add . and status'  '\n      +\tcd \"${base_path}\" &&\n      +\tcd main &&\n     -+\tGIT_TRACE=1 git add --force . &&\n     ++\tGIT_TRACE=1 git add --include-ignored-submodules . &&\n      +\t! git status --porcelain | grep \"^M  sub$\" &&\n      +\techo\n      +'\n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +'\n      +\n      +#8\n     -+# check that 'git add --force sub' does stage the change in the submodule\n     -+# check that 'git add --force ./sub/' does stage the change in the submodule\n     ++# check that 'git add --include-ignored-submodules sub' does stage the change in the submodule\n     ++# check that 'git add --include-ignored-submodules ./sub/' does stage the change in the submodule\n      +# and that 'git status --porcelain' does show it as modified\n      +# commit it..\n      +# check that 'git log --ignore-submodules=none' shows the submodule change\n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +test_expect_success 'main: check force add sub and ./sub/ and status'  '\n      +\tcd \"${base_path}\" &&\n      +\tcd main &&\n     -+\techo \"Adding with --force should work: git add --force sub\" &&\n     -+\tGIT_TRACE=1 git add --force sub &&\n     ++\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules sub\" &&\n     ++\tGIT_TRACE=1 git add --include-ignored-submodules sub &&\n      +\tgit status --porcelain | grep \"^M  sub$\" &&\n      +\tgit restore --staged sub &&\n      +\t! git status --porcelain | grep \"^M  sub$\" &&\n     -+\techo \"Adding with --force should work: git add --force ./sub/\" &&\n     -+\tGIT_TRACE=1 git add --force ./sub/ &&\n     ++\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules ./sub/\" &&\n     ++\tGIT_TRACE=1 git add --include-ignored-submodules ./sub/ &&\n      +\tgit status --porcelain | grep \"^M  sub$\" &&\n      +\tgit commit -m \"update submodule pointer\" &&\n      +\t! git status --porcelain | grep \"^ M sub$\" &&\n 4:  58563a7b90 ! 4:  93c95954f1 tests: fix existing tests when add an ignore=all submodule\n     @@ Metadata\n       ## Commit message ##\n          tests: fix existing tests when add an ignore=all submodule\n      \n     -    There are tests that rely on \"git add <submodule>\" also adds it. A --force\n     -    is needed with this enhancement hence they are added accordingly in these\n     -    tests.\n     +    There are tests that rely on \"git add <submodule>\" to add updates in the\n     +    parent repository. A new option --include-ignored-submodules is introduced\n     +    as it is now needed with this enhancement.\n      \n          Updated tests:\n          - t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n     +    - t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n          - t7406-submodule-update.sh\n          - t7508-status.sh\n      \n     @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n       \t\t\tgit push origin modifications\n       \t\t) &&\n      -\t\tgit add sub1 &&\n     -+\t\tgit add --force sub1 &&\n     ++\t\tgit add --include-ignored-submodules sub1 &&\n       \t\tgit commit -m \"Modify sub1\" &&\n       \n       \t\tgit checkout -b add_nested_sub modify_sub1 &&\n     @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n       \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n       \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n      -\t\tgit add sub1 &&\n     -+\t\tgit add --force sub1 &&\n     ++\t\tgit add --include-ignored-submodules sub1 &&\n       \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n       \t\tgit checkout -b modify_sub1_recursively &&\n       \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n     @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n       \t\tgit -C sub1 add sub2 &&\n       \t\tgit -C sub1 commit -m \"update nested sub\" &&\n      -\t\tgit add sub1 &&\n     -+\t\tgit add --force sub1 &&\n     ++\t\tgit add --include-ignored-submodules sub1 &&\n       \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n       \t\tgit -C sub1 push origin modify_sub1_recursively &&\n       \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\n     @@ t/t7508-status.sh: test_expect_success 'git commit will commit a staged but igno\n       test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n       \tgit reset HEAD^ &&\n      -\tgit add sm &&\n     -+\tgit add --force sm &&\n     ++\tgit add --include-ignored-submodules sm &&\n       \tcat >expect << EOF &&\n       On branch main\n       Your branch and '\\''upstream'\\'' have diverged,\n 5:  416695f439 < -:  ---------- Documentation: update add --force and submodule ignore=all config\n -:  ---------- > 5:  ee84190cd8 Documentation: add --include_ignored_submodules + ignore=all config\n\n-- \ngitgitgadget\n"},{"id":"530654","messageId":"5796009122c6ab573a2961db598bbd33727a6ac0.1763057433.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"[PATCH v2 1/5] read-cache: update add_files_to_cache take param include_ignored_submodules","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-13T18:10:29Z","receivedAt":"2025-11-13T18:10:36Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe include_ignored_submodules parameter is added to the function\nadd_files_to_cache for usage of explicit updating the index for the updated\nsubmodule using the explicit patchspec to the submodule.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n builtin/add.c      |  4 +++-\n builtin/checkout.c |  2 +-\n builtin/commit.c   |  2 +-\n read-cache-ll.h    |  2 +-\n read-cache.c       | 51 ++++++++++++++++++++++++++++++++++++++++++++--\n 5 files changed, 55 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0235854f80..6d11382f33 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -233,6 +233,7 @@ N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n static int verbose, show_only, ignored_too, refresh_only;\n static int ignore_add_errors, intent_to_add, ignore_missing;\n static int warn_on_embedded_repo = 1;\n+static int include_ignored_submodules;\n \n #define ADDREMOVE_DEFAULT 1\n static int addremove = ADDREMOVE_DEFAULT;\n@@ -271,6 +272,7 @@ static struct option builtin_add_options[] = {\n \tOPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n \tOPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n \tOPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n+    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n \tOPT_STRING(0, \"chmod\", &chmod_arg, \"(+|-)x\",\n \t\t   N_(\"override the executable bit of the listed files\")),\n \tOPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n@@ -582,7 +584,7 @@ int cmd_add(int argc,\n \telse\n \t\texit_status |= add_files_to_cache(repo, prefix,\n \t\t\t\t\t\t  &pathspec, ps_matched,\n-\t\t\t\t\t\t  include_sparse, flags);\n+\t\t\t\t\t\t  include_sparse, flags, include_ignored_submodules);\n \n \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n \t    report_path_error(ps_matched, &pathspec))\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex f9453473fe..b2a404051d 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -899,7 +899,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t\t */\n \n \t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n-\t\t\t\t\t   0);\n+\t\t\t\t\t   0, 0 );\n \t\t\tinit_ui_merge_options(&o, the_repository);\n \t\t\to.verbosity = 0;\n \t\t\twork = write_in_core_index_as_tree(the_repository);\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex b5b9608813..5bf7ae5fc1 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -455,7 +455,7 @@ static const char *prepare_index(const char **argv, const char *prefix,\n \t\trepo_hold_locked_index(the_repository, &index_lock,\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\tadd_files_to_cache(the_repository, also ? prefix : NULL,\n-\t\t\t\t   &pathspec, ps_matched, 0, 0);\n+\t\t\t\t   &pathspec, ps_matched, 0, 0, 0 );\n \t\tif (!all && report_path_error(ps_matched, &pathspec))\n \t\t\texit(128);\n \ndiff --git a/read-cache-ll.h b/read-cache-ll.h\nindex 71b49d9af4..2c8b4b21b1 100644\n--- a/read-cache-ll.h\n+++ b/read-cache-ll.h\n@@ -481,7 +481,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags);\n+\t\t       int include_sparse, int flags, int ignored_too );\n \n void overlay_tree_on_index(struct index_state *istate,\n \t\t\t   const char *tree_name, const char *prefix);\ndiff --git a/read-cache.c b/read-cache.c\nindex 06ad74db22..32f32bdb4c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3880,9 +3880,12 @@ void overlay_tree_on_index(struct index_state *istate,\n \n struct update_callback_data {\n \tstruct index_state *index;\n+\tstruct repository *repo;\n+\tstruct pathspec *pathspec;\n \tint include_sparse;\n \tint flags;\n \tint add_errors;\n+\tint include_ignored_submodules;\n };\n \n static int fix_unmerged_status(struct diff_filepair *p,\n@@ -3924,7 +3927,48 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tdefault:\n \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n \t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n+\t\t\tstruct stat st;\n+\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n+\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n+\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n+\t\t\t\t\tint pathspec_matches = 0;\n+\t\t\t\t\tchar *norm_pathspec = NULL;\n+\t\t\t\t\tint ps_i;\n+\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n+\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n+\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n+\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n+\t\t\t\t\tif (data->pathspec) {\n+\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n+\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n+\t\t\t\t\t\t\tif (!m)\n+\t\t\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n+\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n+\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n+\t\t\t\t\t\t\t\tpathspec_matches = 1;\n+\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t\t\t\t\t\t\tbreak;\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t\tif (pathspec_matches) {\n+\t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n+\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n+\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n+\t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n+\t\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n+\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n+\t\t\t\t\t\tcontinue;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n \t\t\t\t\tdie(_(\"updating files failed\"));\n@@ -3945,7 +3989,7 @@ static void update_callback(struct diff_queue_struct *q,\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags)\n+\t\t       int include_sparse, int flags, int include_ignored_submodules )\n {\n \tstruct update_callback_data data;\n \tstruct rev_info rev;\n@@ -3954,6 +3998,9 @@ int add_files_to_cache(struct repository *repo, const char *prefix,\n \tdata.index = repo->index;\n \tdata.include_sparse = include_sparse;\n \tdata.flags = flags;\n+\tdata.repo = repo;\n+\tdata.include_ignored_submodules = include_ignored_submodules;\n+\tdata.pathspec = (struct pathspec *)pathspec;\n \n \trepo_init_revisions(repo, &rev, prefix);\n \tsetup_revisions(0, NULL, &rev, NULL);\n-- \ngitgitgadget\n\n"},{"id":"530655","messageId":"9ec79b9a116a1dda9fe7bd10d16c1faf77f778ed.1763057433.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"[PATCH v2 2/5] read-cache: add/read-cache respect submodule ignore=all","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-13T18:10:30Z","receivedAt":"2025-11-13T18:10:38Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nSubmodules configured with ignore=all are now skipped during add operations\nunless overridden by --include-ignored-submodules and the submodule path is\nexplicitly specified.\n\nA message is printed (like ignored files) guiding the user to use the\n--include-ignored-submodules flag if the user has explicitely want to update\nthe submodule reference.\n\nThe reason for the change is support submodule branch tracking or\nsimilar and git status state nothing and git add should not add either.\nThe workflow is more logic and similar to regular ignored files even\nthe submodule is already tracked.\n\nThe change opens up a lot of possibilities for submodules to be used\nmore freely and simular to the repo tool. A submodule can be added for many\nmore reason and loosely coupled dependencies to the super repo which often\ngives the friction of handle the explicit commits and updates without\nthe need for tracking the submodule sha1 by sha1.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n read-cache.c | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 32f32bdb4c..7b6d1b2914 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -48,6 +48,8 @@\n #include \"csum-file.h\"\n #include \"promisor-remote.h\"\n #include \"hook.h\"\n+#include \"submodule.h\"\n+#include \"submodule-config.h\"\n \n /* Mask for the name length in ce_flags in the on-disk index */\n \n@@ -3956,7 +3958,7 @@ static void update_callback(struct diff_queue_struct *q,\n \t\t\t\t\t}\n \t\t\t\t\tif (pathspec_matches) {\n \t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n-\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n+\t\t\t\t\t\t\ttrace_printf(\"Add submodule due to --include_ignored_submodules: %s\\n\", path);\n \t\t\t\t\t\t} else {\n \t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n \t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n@@ -3964,7 +3966,7 @@ static void update_callback(struct diff_queue_struct *q,\n \t\t\t\t\t\t}\n \t\t\t\t\t} else {\n \t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n-\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n+\t\t\t\t\t\ttrace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n \t\t\t\t\t\tcontinue;\n \t\t\t\t\t}\n \t\t\t\t}\n@@ -3975,6 +3977,7 @@ static void update_callback(struct diff_queue_struct *q,\n \t\t\t\tdata->add_errors++;\n \t\t\t}\n \t\t\tbreak;\n+\t\t}\n \t\tcase DIFF_STATUS_DELETED:\n \t\t\tif (data->flags & ADD_CACHE_IGNORE_REMOVAL)\n \t\t\t\tbreak;\n-- \ngitgitgadget\n\n"},{"id":"530656","messageId":"399a153b9563ec2ce3cf1ceebda2004c13e1dbe3.1763057433.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"[PATCH v2 3/5] tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-13T18:10:31Z","receivedAt":"2025-11-13T18:10:39Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe tests verify that the submodule behavior is intact and updating the\nconfig with ignore=all also behaves as intended with configuration in\n.gitmodules and configuration given on the command line.\n\nThe usage of --include_ignored_submodules is showcased and tested in the\ntest suite.\n\nThe test file is added to meson.build for execution.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/meson.build                    |   1 +\n t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n 2 files changed, 135 insertions(+)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\ndiff --git a/t/meson.build b/t/meson.build\nindex 983245501c..49e29ae82f 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -282,6 +282,7 @@ integration_tests = [\n   't2203-add-intent.sh',\n   't2204-add-ignored.sh',\n   't2205-add-worktree-config.sh',\n+  't2206-add-submodule-ignored.sh',\n   't2300-cd-to-toplevel.sh',\n   't2400-worktree-add.sh',\n   't2401-worktree-prune.sh',\ndiff --git a/t/t2206-add-submodule-ignored.sh b/t/t2206-add-submodule-ignored.sh\nnew file mode 100755\nindex 0000000000..2c8a523641\n--- /dev/null\n+++ b/t/t2206-add-submodule-ignored.sh\n@@ -0,0 +1,134 @@\n+#!/bin/sh\n+# shellcheck disable=SC2016\n+\n+# shellcheck disable=SC2034\n+test_description='git add respects submodule ignore=all and explicit pathspec'\n+\n+# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n+# dealing with submodules that have the ignore=all setting in\n+# .gitmodules. It ensures that changes in such submodules are\n+# ignored by default, but can be staged with \"git add --include-ignored-submodules\".\n+\n+# shellcheck disable=SC1091\n+. ./test-lib.sh\n+\n+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n+base_path=$(pwd -P)\n+\n+#1\n+test_expect_success 'setup: create origin repos'  '\n+\tcd \"${base_path}\" &&\n+\tgit config --global protocol.file.allow always &&\n+\tgit init sub &&\n+\t\tpwd &&\n+\t\tcd sub &&\n+\t\ttest_commit sub_file1 &&\n+\t\tgit tag v1.0 &&\n+\t\ttest_commit sub_file2 &&\n+\t\tgit tag v2.0 &&\n+\t\ttest_commit sub_file3 &&\n+\t\tgit tag v3.0 &&\n+\tcd \"${base_path}\" &&\n+\tgit init main &&\n+\t\tcd main &&\n+\t\ttest_commit first &&\n+\tcd \"${base_path}\"\n+'\n+#2\n+# add submodule with default config (ignore=none) and\n+# check log that is contains a path entry for the submodule 'sub'\n+# change the commit in the submodule and check that 'git status' shows it as modified\n+test_expect_success 'main: add submodule with default config'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit submodule add ../sub &&\n+\tgit commit -m \"add submodule\" &&\n+\tgit log --oneline --name-only | grep \"^sub$\" &&\n+\tgit -C sub reset --hard v2.0 &&\n+\tgit status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+#3\n+# change the submodule config to ignore=all and check that status and log do not show changes\n+test_expect_success 'main: submodule config ignore=all'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit config -f .gitmodules submodule.sub.ignore all &&\n+\tGIT_TRACE=1 git add . &&\n+\tgit commit -m \"update submodule config sub.ignore all\" &&\n+\t! git status --porcelain | grep \"^.*$\" &&\n+\t! git log --oneline --name-only | grep \"^sub$\" &&\n+\techo\n+'\n+#4\n+# change the commit in the submodule and check that 'git status' does not show it as modified\n+# but 'git status --ignore-submodules=none' does show it as modified\n+test_expect_success 'sub: change to different sha1 and check status in main'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit -C sub reset --hard v1.0 &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit status --ignore-submodules=none --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#5\n+# check that normal 'git add' does not stage the change in the submodule\n+test_expect_success 'main: check normal add and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add . &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#6\n+# check that 'git add --include-ignored-submodules .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check --include-ignored-submodules add . and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add --include-ignored-submodules . &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#7\n+# check that 'git add .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check _add sub_ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add sub | grep \"Skipping submodule due to ignore=all: sub\" &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#8\n+# check that 'git add --include-ignored-submodules sub' does stage the change in the submodule\n+# check that 'git add --include-ignored-submodules ./sub/' does stage the change in the submodule\n+# and that 'git status --porcelain' does show it as modified\n+# commit it..\n+# check that 'git log --ignore-submodules=none' shows the submodule change\n+# in the log\n+test_expect_success 'main: check force add sub and ./sub/ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules sub\" &&\n+\tGIT_TRACE=1 git add --include-ignored-submodules sub &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit restore --staged sub &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules ./sub/\" &&\n+\tGIT_TRACE=1 git add --include-ignored-submodules ./sub/ &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit commit -m \"update submodule pointer\" &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit log --ignore-submodules=none --name-only --oneline | grep \"^sub$\" &&\n+\techo\n+'\n+\n+test_done\n+exit 0\n-- \ngitgitgadget\n\n"},{"id":"530657","messageId":"93c95954f1fad9d52489798b7f9da0c94f92f79a.1763057433.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"[PATCH v2 4/5] tests: fix existing tests when add an ignore=all submodule","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-13T18:10:32Z","receivedAt":"2025-11-13T18:10:40Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThere are tests that rely on \"git add <submodule>\" to add updates in the\nparent repository. A new option --include-ignored-submodules is introduced\nas it is now needed with this enhancement.\n\nUpdated tests:\n- t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t7406-submodule-update.sh\n- t7508-status.sh\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/lib-submodule-update.sh | 6 +++---\n t/t7508-status.sh         | 2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 36f767cb74..fde5dbee02 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -95,14 +95,14 @@ create_lib_submodule_repo () {\n \t\t\tgit commit -m \"modified file2 and added file3\" &&\n \t\t\tgit push origin modifications\n \t\t) &&\n-\t\tgit add sub1 &&\n+\t\tgit add --include-ignored-submodules sub1 &&\n \t\tgit commit -m \"Modify sub1\" &&\n \n \t\tgit checkout -b add_nested_sub modify_sub1 &&\n \t\tgit -C sub1 checkout -b \"add_nested_sub\" &&\n \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --include-ignored-submodules sub1 &&\n \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n \t\tgit checkout -b modify_sub1_recursively &&\n \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n@@ -112,7 +112,7 @@ create_lib_submodule_repo () {\n \t\tgit -C sub1/sub2 commit -m \"make a change in nested sub\" &&\n \t\tgit -C sub1 add sub2 &&\n \t\tgit -C sub1 commit -m \"update nested sub\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --include-ignored-submodules sub1 &&\n \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n \t\tgit -C sub1 push origin modify_sub1_recursively &&\n \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex cdc1d6fcc7..5c8ffed21b 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1565,7 +1565,7 @@ test_expect_success 'git commit will commit a staged but ignored submodule' '\n \n test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n \tgit reset HEAD^ &&\n-\tgit add sm &&\n+\tgit add --include-ignored-submodules sm &&\n \tcat >expect << EOF &&\n On branch main\n Your branch and '\\''upstream'\\'' have diverged,\n-- \ngitgitgadget\n\n"},{"id":"530658","messageId":"ee84190cd899a3954095bf7263744704bfa4fa85.1763057433.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"[PATCH v2 5/5] Documentation: add --include_ignored_submodules + ignore=all config","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-11-13T18:10:33Z","receivedAt":"2025-11-13T18:10:41Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\n- git-add.adoc: Add new documentation for --include_ignored_submodules\n  option to supress ignore=all and new submodule functionality of not\n  adding a ignore=all submodule by default.\n- gitmodules.adoc and config/submodule.adoc: The submodule config\n  ignore=all now need --include_ignored_submodules in order to update\n  the index.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n .devcontainer/Dockerfile            | 70 ++++++++++++++++++++++++++\n .devcontainer/Dockerfile.standalone | 76 +++++++++++++++++++++++++++++\n .devcontainer/devcontainer.json     | 25 ++++++++++\n Documentation/config/submodule.adoc | 13 ++---\n Documentation/git-add.adoc          |  5 ++\n Documentation/gitmodules.adoc       |  5 +-\n 6 files changed, 187 insertions(+), 7 deletions(-)\n create mode 100644 .devcontainer/Dockerfile\n create mode 100644 .devcontainer/Dockerfile.standalone\n create mode 100644 .devcontainer/devcontainer.json\n\ndiff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile\nnew file mode 100644\nindex 0000000000..680ca5f3ad\n--- /dev/null\n+++ b/.devcontainer/Dockerfile\n@@ -0,0 +1,70 @@\n+FROM ubuntu:latest\n+\n+ARG USER_ID\n+ARG GROUP_ID\n+\n+ENV DEBIAN_FRONTEND=noninteractive\n+ENV TZ=Europe/Copenhagen\n+\n+RUN apt-get update \\\n+    && \\\n+    apt-get install -y \\\n+        sudo \\\n+        build-essential \\\n+        libcurl4-gnutls-dev \\\n+        libexpat1-dev \\\n+        gettext \\\n+        libz-dev \\\n+        libssl-dev \\\n+        asciidoc \\\n+        xmlto \\\n+        docbook-xsl \\\n+        \\\n+        tzdata \\\n+        git \\\n+        coccinelle \\\n+    && \\\n+    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \\\n+    && \\\n+    dpkg-reconfigure --frontend noninteractive tzdata\n+\n+RUN  apt-get update && apt-get install -y autoconf\n+\n+RUN addgroup -gid 1001 gituser\n+RUN adduser --disabled-password -u 1001 -gid 1001 gituser\n+RUN usermod -aG sudo gituser\n+RUN echo 'gituser ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/010-gituser\n+RUN chmod 0440 /etc/sudoers.d/010-gituser\n+\n+USER 1001\n+\n+#WORKDIR /home/gituser/git-src/\n+\n+#RUN  make configure\n+#RUN ./configure --prefix=${HOME}/.local/\n+\n+#RUN make -j$(nproc) gitweb || make gitweb \n+#RUN make install-gitweb\n+\n+#RUN make -j$(nproc) || make\n+#RUN make -j$(nproc) gitweb || make gitweb \n+#RUN make install-gitweb\n+#RUN make -j$(nproc) NO_PERL=YesPlease install || make NO_PERL=YesPlease install\n+#RUN make install\n+\n+\n+RUN mkdir -p  ${HOME}/.local/\n+#RUN ls -la ${HOME}/.local/bin\n+#ENV PATH=\"/home/gituser/.local/bin:${PATH}\"\n+#RUN ls -l $HOME/.local/bin\n+#RUN echo $PATH $HOME \n+\n+#RUN git --version\n+#RUN which git \n+\n+RUN git config --global user.email \"gituser@example.com\"\n+RUN git config --global user.name \"Git User\"\n+\n+#WORKDIR /home/gituser/git-test/\n+\n+#CMD [ \"git\" ]\ndiff --git a/.devcontainer/Dockerfile.standalone b/.devcontainer/Dockerfile.standalone\nnew file mode 100644\nindex 0000000000..39bda42c0e\n--- /dev/null\n+++ b/.devcontainer/Dockerfile.standalone\n@@ -0,0 +1,76 @@\n+FROM ubuntu:latest\n+\n+ARG USER_ID\n+ARG GROUP_ID\n+\n+ENV DEBIAN_FRONTEND=noninteractive\n+ENV TZ=Europe/Copenhagen\n+\n+RUN apt-get update \\\n+    && \\\n+    apt-get install -y \\\n+        build-essential \\\n+        libcurl4-gnutls-dev \\\n+        libexpat1-dev \\\n+        gettext \\\n+        libz-dev \\\n+        libssl-dev \\\n+        asciidoc \\\n+        xmlto \\\n+        docbook-xsl \\\n+        \\\n+        tzdata \\\n+        \\\n+        nano \\\n+        vim \\\n+    && \\\n+    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \\\n+    && \\\n+    dpkg-reconfigure --frontend noninteractive tzdata\n+\n+RUN  apt-get update && apt-get install -y autoconf\n+\n+RUN addgroup -gid ${GROUP_ID} gituser\n+RUN adduser --disabled-password -u ${USER_ID} -gid ${GROUP_ID} gituser\n+\n+\n+COPY --chown=${USER_ID}:${GROUP_ID} ./git /home/gituser/git-src/\n+\n+USER ${USER_ID}\n+\n+WORKDIR /home/gituser/git-src/\n+\n+RUN  make configure\n+RUN ./configure --prefix=${HOME}/.local/\n+\n+#RUN make -j$(nproc) gitweb || make gitweb \n+#RUN make install-gitweb\n+\n+#RUN make -j$(nproc) || make\n+#RUN make -j$(nproc) gitweb || make gitweb \n+#RUN make install-gitweb\n+RUN make -j$(nproc) NO_PERL=YesPlease install || make NO_PERL=YesPlease install\n+RUN make install\n+\n+WORKDIR /home/gituser/git-src/t\n+RUN ./t2206-add-submodule-ignored.sh -v\n+\n+RUN ls -la ${HOME}/.local/\n+RUN ls -la ${HOME}/.local/bin\n+ENV PATH=\"/home/gituser/.local/bin:${PATH}\"\n+RUN ls -l $HOME/.local/bin\n+RUN echo $PATH $HOME \n+\n+RUN git --version\n+RUN which git \n+\n+RUN git config --global user.email \"gituser@example.com\"\n+RUN git config --global user.name \"Git User\"\n+\n+WORKDIR /home/gituser/git-src/t\n+RUN pwd && ls -la \n+RUN ./t2206-add-submodule-ignored.sh -v\n+\n+WORKDIR /home/gituser/git-test/\n+\n+CMD [ \"git\" ]\ndiff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json\nnew file mode 100644\nindex 0000000000..2bc13902d8\n--- /dev/null\n+++ b/.devcontainer/devcontainer.json\n@@ -0,0 +1,25 @@\n+{\n+  \"name\": \"Git Dev Container\",\n+  \"build\": {\n+    \"dockerfile\": \"Dockerfile\",\n+    \"context\": \"\",\n+    \"args\": {\n+      \"user_id\": \"1001\",\n+      \"group_id\": \"1001\"\n+    }\n+  },\n+  \"customizations\": {\n+    \"vscode\": {\n+      \"settings\": {\n+        \"terminal.integrated.shell.linux\": \"/bin/bash\"\n+      }\n+    }\n+  },\n+  \"remoteUser\": \"gituser\",\n+  \"features\": {},\n+  \"mounts\": [\n+    \"source=${localWorkspaceFolder}/,target=/home/gitusers/git-src,type=bind,consistency=cached\",\n+    \"source=${localWorkspaceFolder}/,target=/home/gitusers/git-test,type=bind,consistency=cached\"\n+  ],\n+  \"postCreateCommand\": \"echo\"\n+}\ndiff --git a/Documentation/config/submodule.adoc b/Documentation/config/submodule.adoc\nindex 0672d99117..0753adbab5 100644\n--- a/Documentation/config/submodule.adoc\n+++ b/Documentation/config/submodule.adoc\n@@ -32,15 +32,16 @@ submodule.<name>.fetchRecurseSubmodules::\n \n submodule.<name>.ignore::\n \tDefines under what circumstances \"git status\" and the diff family show\n-\ta submodule as modified. When set to \"all\", it will never be considered\n-\tmodified (but it will nonetheless show up in the output of status and\n-\tcommit when it has been staged), \"dirty\" will ignore all changes\n-\tto the submodule's work tree and\n+\ta submodule as modified.\n+\tSet to \"all\" will never considered the submodule modified. It can\n+\tnevertheless be staged using the option --include_ignored_submodules and\n+\tit will then show up in the output of status.\n+\tSet to \"dirty\" will ignore all changes to the submodule's work tree and\n \ttakes only differences between the HEAD of the submodule and the commit\n \trecorded in the superproject into account. \"untracked\" will additionally\n \tlet submodules with modified tracked files in their work tree show up.\n-\tUsing \"none\" (the default when this option is not set) also shows\n-\tsubmodules that have untracked files in their work tree as changed.\n+\tSet to \"none\"(default) It is also shows submodules that have untracked\n+\tfiles in their work tree as changed.\n \tThis setting overrides any setting made in .gitmodules for this submodule,\n \tboth settings can be overridden on the command line by using the\n \t\"--ignore-submodules\" option. The 'git submodule' commands are not\ndiff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\nindex b7a735824d..ab72fad651 100644\n--- a/Documentation/git-add.adoc\n+++ b/Documentation/git-add.adoc\n@@ -79,6 +79,11 @@ in linkgit:gitglossary[7].\n `--force`::\n \tAllow adding otherwise ignored files.\n \n+`--include_ignored_submodules`::\n+\tThe option is also used when `submodule.<name>.ignore=all`\n+\tis set, but you want to stage an update of the submodule. The\n+\t`path` to the submodule must be explicitly specified.\n+\n `--sparse`::\n \tAllow updating index entries outside of the sparse-checkout cone.\n \tNormally, `git add` refuses to update index entries whose paths do\ndiff --git a/Documentation/gitmodules.adoc b/Documentation/gitmodules.adoc\nindex d9bec8b187..ea1fd377e6 100644\n--- a/Documentation/gitmodules.adoc\n+++ b/Documentation/gitmodules.adoc\n@@ -70,7 +70,10 @@ submodule.<name>.ignore::\n --\n \tall;; The submodule will never be considered modified (but will\n \t    nonetheless show up in the output of status and commit when it has\n-\t    been staged).\n+\t    been staged). Add `(new commits)` can be overruled using the\n+\t    `git add --include_ignored_submodules <submodule.path>` \n+\t\tThe setting affects `status`, `update-index`, `diff` and `log`(due \n+\t\tto underlaying `diff`).\n \n \tdirty;; All changes to the submodule's work tree will be ignored, only\n \t    committed differences between the `HEAD` of the submodule and its\n-- \ngitgitgadget\n"},{"id":"530660","messageId":"xmqqzf8pln62.fsf@gitster.g","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-13T19:58:45Z","receivedAt":"2025-11-13T19:58:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Claus Schneider via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> The feature of configuring a submodule to \"ignore=all\" is nicely respected\n> in commands \"status\" and \"diff\".\n\n\"nicely respected\" is not very informative for those who do not know\nwhat the setting does.  Saying something like\n\n    \"git status\" and \"git diff\" will not report modified submodules\n    with submodule.<name>.ignore set to \"all\".\n\nwould not waste significantly more bytes than what you wrote, and is\nmore helpful.\n\n> However the \"add\" command does not respect\n> the configuration the same way.\n\nAgain, \"does not respect\" and then what?  Running \"git add\" on a\nsubmodule with submodule.<name>.ignore set to \"all\" does what?\nComplains that it has changes but because .ignore is set it won't\nadd?  Adds it silently?  Something else?\n\n> The behavior is problematic for the logic\n> between status/diff and add.\n\nAfter this sentence, \"because ...\" is missing.  Please help readers\nunderstand the issue you perceive as problematic more easily.\n\nI am guessing that you are assuming that an \"add\", after \"diff\" or\n\"status\" said there is no change, is expected to be a no-op, but I\ncannot be sure if that is what you are referring to here with the\nreason left unsaid like the above.\n\n> Secondly it makes it problematic to track\n> branches in the submodule configuration as developers unintentionally keeps\n> add submodule updates and get conflicts for no intentional reason. Both adds\n> unnecessary friction to the usage of submodules.\n>\n> The patches implement the same logical behavior for ignore=all submodules as\n> regular ignored files. The status now does not show any diff - nor will the\n> add command update the reference submodule reference. If you add the\n> submodule path which is ignore=all then you are presented with a message\n> that you need to use the --force option.\n\nI vaguely recall that an earlier discussion between you and Phillip\nwere concluding against \"--force\"?  I personally feel it is in line\nwith \"git add foo.o\" (when '*.o' is in .gitignore) gets rejected and\n\"git add -f foo.o\" is a way to override it, but in the list of\npatches below, I see --include-ignored-submodules (no, our command\nline option names do not use underscore for inter-word-gaps), so I\nsuspect the description in the cover letter around here is stale?\n\n\n> The branch=, ignore=all (and\n> update=none) now works great with update --remote,\n\nAgain, \"great\" is not very informative, and as bad as \"nicely\nrespected\".  Avoid using these adjectives loaded with unnecessary\nvalue judgements, and instead trust your readers.  They are\nintelligent to judge if the updated behaviour is great or not for\nthemselves.  Try to use the same bytes on helping readers understand\nwhat actually happens.\n\n> but developers does not\n\n\"do not\".\n\n> have to consider changes in the updates of the submodule sha1. The\n> implementation removes a friction of working with submodules and can be used\n> like the repo tool with branches configured. The submodule status report\n> could be used for build/release documentation for reproduction of a setup.\n>\n> A few tests used the adding of submodules without --force, hence they have\n> been updated to use the --force option.\n>\n> Claus Schneider(Eficode) (5):\n>   read-cache: update add_files_to_cache take param\n>     include_ignored_submodules\n>   read-cache: add/read-cache respect submodule ignore=all\n>   tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n>     scenario\n>   tests: fix existing tests when add an ignore=all submodule\n>   Documentation: add --include_ignored_submodules + ignore=all config\n>\n>  .devcontainer/Dockerfile            |  70 +++++++++++++++\n>  .devcontainer/Dockerfile.standalone |  76 ++++++++++++++++\n>  .devcontainer/devcontainer.json     |  25 ++++++\n>  Documentation/config/submodule.adoc |  13 +--\n>  Documentation/git-add.adoc          |   5 ++\n>  Documentation/gitmodules.adoc       |   5 +-\n>  builtin/add.c                       |   4 +-\n>  builtin/checkout.c                  |   2 +-\n>  builtin/commit.c                    |   2 +-\n>  read-cache-ll.h                     |   2 +-\n>  read-cache.c                        |  54 ++++++++++-\n>  t/lib-submodule-update.sh           |   6 +-\n>  t/meson.build                       |   1 +\n>  t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++\n>  t/t7508-status.sh                   |   2 +-\n>  15 files changed, 384 insertions(+), 17 deletions(-)\n>  create mode 100644 .devcontainer/Dockerfile\n>  create mode 100644 .devcontainer/Dockerfile.standalone\n>  create mode 100644 .devcontainer/devcontainer.json\n>  create mode 100755 t/t2206-add-submodule-ignored.sh\n>\n>\n> base-commit: 81f86aacc4eb74cdb9c2c8082d36d2070c666045\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v2\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v2\n> Pull-Request: https://github.com/gitgitgadget/git/pull/1987\n>\n> Range-diff vs v1:\n>\n>  1:  d98cca698d ! 1:  5796009122 read-cache: update add_files_to_cache to take param ignored_too(--force)\n>      @@ Metadata\n>       Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n>       \n>        ## Commit message ##\n>      -    read-cache: update add_files_to_cache to take param ignored_too(--force)\n>      +    read-cache: update add_files_to_cache take param include_ignored_submodules\n>       \n>      -    The ignored_too parameter is added to the function add_files_to_cache for\n>      -    usage of explicit updating the index for the updated submodule using the\n>      -    explicit patchspec to the submodule.\n>      +    The include_ignored_submodules parameter is added to the function\n>      +    add_files_to_cache for usage of explicit updating the index for the updated\n>      +    submodule using the explicit patchspec to the submodule.\n>       \n>           Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n>       \n>        ## builtin/add.c ##\n>      +@@ builtin/add.c: N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n>      + static int verbose, show_only, ignored_too, refresh_only;\n>      + static int ignore_add_errors, intent_to_add, ignore_missing;\n>      + static int warn_on_embedded_repo = 1;\n>      ++static int include_ignored_submodules;\n>      + \n>      + #define ADDREMOVE_DEFAULT 1\n>      + static int addremove = ADDREMOVE_DEFAULT;\n>      +@@ builtin/add.c: static struct option builtin_add_options[] = {\n>      + \tOPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n>      + \tOPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n>      + \tOPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n>      ++    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n>      + \tOPT_STRING(0, \"chmod\", &chmod_arg, \"(+|-)x\",\n>      + \t\t   N_(\"override the executable bit of the listed files\")),\n>      + \tOPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n>       @@ builtin/add.c: int cmd_add(int argc,\n>        \telse\n>        \t\texit_status |= add_files_to_cache(repo, prefix,\n>        \t\t\t\t\t\t  &pathspec, ps_matched,\n>       -\t\t\t\t\t\t  include_sparse, flags);\n>      -+\t\t\t\t\t\t  include_sparse, flags, ignored_too);\n>      ++\t\t\t\t\t\t  include_sparse, flags, include_ignored_submodules);\n>        \n>        \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n>        \t    report_path_error(ps_matched, &pathspec))\n>      @@ read-cache.c: void overlay_tree_on_index(struct index_state *istate,\n>        \tint include_sparse;\n>        \tint flags;\n>        \tint add_errors;\n>      -+\tint ignored_too;\n>      ++\tint include_ignored_submodules;\n>        };\n>        \n>        static int fix_unmerged_status(struct diff_filepair *p,\n>       @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n>      + \t\tdefault:\n>      + \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n>      + \t\tcase DIFF_STATUS_MODIFIED:\n>      +-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n>      ++\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n>      ++\t\t\tstruct stat st;\n>      ++\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n>      ++\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n>      ++\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n>      ++\t\t\t\t\tint pathspec_matches = 0;\n>      ++\t\t\t\t\tchar *norm_pathspec = NULL;\n>      ++\t\t\t\t\tint ps_i;\n>      ++\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n>      ++\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n>      ++\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n>      ++\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n>      ++\t\t\t\t\tif (data->pathspec) {\n>      ++\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n>      ++\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n>      ++\t\t\t\t\t\t\tif (!m)\n>      ++\t\t\t\t\t\t\t\tcontinue;\n>      ++\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n>      ++\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n>      ++\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n>      ++\t\t\t\t\t\t\t\tpathspec_matches = 1;\n>      ++\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n>      ++\t\t\t\t\t\t\t\tbreak;\n>      ++\t\t\t\t\t\t\t}\n>      ++\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n>      ++\t\t\t\t\t\t}\n>      ++\t\t\t\t\t}\n>      ++\t\t\t\t\tif (pathspec_matches) {\n>      ++\t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n>      ++\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n>      ++\t\t\t\t\t\t} else {\n>      ++\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n>      ++\t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n>      ++\t\t\t\t\t\t\tcontinue;\n>      ++\t\t\t\t\t\t}\n>      ++\t\t\t\t\t} else {\n>      ++\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n>      ++\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n>      ++\t\t\t\t\t\tcontinue;\n>      ++\t\t\t\t\t}\n>      ++\t\t\t\t}\n>      ++\t\t\t}\n>      + \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n>      + \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n>      + \t\t\t\t\tdie(_(\"updating files failed\"));\n>      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n>        \n>        int add_files_to_cache(struct repository *repo, const char *prefix,\n>        \t\t       const struct pathspec *pathspec, char *ps_matched,\n>       -\t\t       int include_sparse, int flags)\n>      -+\t\t       int include_sparse, int flags, int ignored_too )\n>      ++\t\t       int include_sparse, int flags, int include_ignored_submodules )\n>        {\n>        \tstruct update_callback_data data;\n>        \tstruct rev_info rev;\n>      @@ read-cache.c: int add_files_to_cache(struct repository *repo, const char *prefix\n>        \tdata.include_sparse = include_sparse;\n>        \tdata.flags = flags;\n>       +\tdata.repo = repo;\n>      -+\tdata.ignored_too = ignored_too;\n>      ++\tdata.include_ignored_submodules = include_ignored_submodules;\n>       +\tdata.pathspec = (struct pathspec *)pathspec;\n>        \n>        \trepo_init_revisions(repo, &rev, prefix);\n>  2:  d1b02617e6 ! 2:  9ec79b9a11 read-cache: let read-cache respect submodule ignore=all and --force\n>      @@ Metadata\n>       Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n>       \n>        ## Commit message ##\n>      -    read-cache: let read-cache respect submodule ignore=all and --force\n>      +    read-cache: add/read-cache respect submodule ignore=all\n>       \n>      -    Given the submdule configuration is ignore=all then only update the\n>      -    submdule if the --force option is given and the submodule is explicit\n>      -    given in the pathspec.\n>      +    Submodules configured with ignore=all are now skipped during add operations\n>      +    unless overridden by --include-ignored-submodules and the submodule path is\n>      +    explicitly specified.\n>       \n>           A message is printed (like ignored files) guiding the user to use the\n>      -    --force flag if the user has explicitely want to update the submodule\n>      -    reference.\n>      +    --include-ignored-submodules flag if the user has explicitely want to update\n>      +    the submodule reference.\n>       \n>           The reason for the change is support submodule branch tracking or\n>           similar and git status state nothing and git add should not add either.\n>      @@ Commit message\n>           the submodule is already tracked.\n>       \n>           The change opens up a lot of possibilities for submodules to be used\n>      -    more freely and a like the repo tool. A submodule can be added for many\n>      +    more freely and simular to the repo tool. A submodule can be added for many\n>           more reason and loosely coupled dependencies to the super repo which often\n>           gives the friction of handle the explicit commits and updates without\n>           the need for tracking the submodule sha1 by sha1.\n>      @@ read-cache.c\n>        /* Mask for the name length in ce_flags in the on-disk index */\n>        \n>       @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n>      - \t\tdefault:\n>      - \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n>      - \t\tcase DIFF_STATUS_MODIFIED:\n>      --\t\tcase DIFF_STATUS_TYPE_CHANGED:\n>      -+\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n>      -+\t\t\tstruct stat st;\n>      -+\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n>      -+\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n>      -+\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n>      -+\t\t\t\t\tint pathspec_matches = 0;\n>      -+\t\t\t\t\tchar *norm_pathspec = NULL;\n>      -+\t\t\t\t\tint ps_i;\n>      -+\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n>      -+\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n>      -+\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n>      -+\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n>      -+\t\t\t\t\tif (data->pathspec) {\n>      -+\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n>      -+\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n>      -+\t\t\t\t\t\t\tif (!m)\n>      -+\t\t\t\t\t\t\t\tcontinue;\n>      -+\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n>      -+\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n>      -+\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n>      -+\t\t\t\t\t\t\t\tpathspec_matches = 1;\n>      -+\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n>      -+\t\t\t\t\t\t\t\tbreak;\n>      -+\t\t\t\t\t\t\t}\n>      -+\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n>      -+\t\t\t\t\t\t}\n>      -+\t\t\t\t\t}\n>      -+\t\t\t\t\tif (pathspec_matches) {\n>      -+\t\t\t\t\t\tif (data->ignored_too && data->ignored_too > 0) {\n>      -+\t\t\t\t\t\t\ttrace_printf(\"Forcing add of submodule ignored=all due to --force: %s\\n\", path);\n>      -+\t\t\t\t\t\t} else {\n>      -+\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n>      -+\t\t\t\t\t\t\tprintf(_(\"Use -f if you really want to add them.\") );\n>      -+\t\t\t\t\t\t\tcontinue;\n>      -+\t\t\t\t\t\t}\n>      -+\t\t\t\t\t} else {\n>      -+\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n>      -+\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n>      -+\t\t\t\t\t\tcontinue;\n>      -+\t\t\t\t\t}\n>      -+\t\t\t\t}\n>      -+\t\t\t}\n>      - \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n>      - \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n>      - \t\t\t\t\tdie(_(\"updating files failed\"));\n>      + \t\t\t\t\t}\n>      + \t\t\t\t\tif (pathspec_matches) {\n>      + \t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n>      +-\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n>      ++\t\t\t\t\t\t\ttrace_printf(\"Add submodule due to --include_ignored_submodules: %s\\n\", path);\n>      + \t\t\t\t\t\t} else {\n>      + \t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n>      + \t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n>      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n>      + \t\t\t\t\t\t}\n>      + \t\t\t\t\t} else {\n>      + \t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n>      +-\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n>      ++\t\t\t\t\t\ttrace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n>      + \t\t\t\t\t\tcontinue;\n>      + \t\t\t\t\t}\n>      + \t\t\t\t}\n>      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n>        \t\t\t\tdata->add_errors++;\n>        \t\t\t}\n>        \t\t\tbreak;\n>  3:  8f3d5f7ec1 ! 3:  399a153b95 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario\n>      @@ Commit message\n>           config with ignore=all also behaves as intended with configuration in\n>           .gitmodules and configuration given on the command line.\n>       \n>      -    Testfile is added to meson.build for execution.\n>      +    The usage of --include_ignored_submodules is showcased and tested in the\n>      +    test suite.\n>      +\n>      +    The test file is added to meson.build for execution.\n>       \n>           Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n>       \n>      @@ t/t2206-add-submodule-ignored.sh (new)\n>       +# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n>       +# dealing with submodules that have the ignore=all setting in\n>       +# .gitmodules. It ensures that changes in such submodules are\n>      -+# ignored by default, but can be staged with \"git add --force\".\n>      ++# ignored by default, but can be staged with \"git add --include-ignored-submodules\".\n>       +\n>       +# shellcheck disable=SC1091\n>       +. ./test-lib.sh\n>      @@ t/t2206-add-submodule-ignored.sh (new)\n>       +'\n>       +\n>       +#6\n>      -+# check that 'git add --force .' does not stage the change in the submodule\n>      ++# check that 'git add --include-ignored-submodules .' does not stage the change in the submodule\n>       +# and that 'git status' does not show it as modified\n>      -+test_expect_success 'main: check --force add . and status'  '\n>      ++test_expect_success 'main: check --include-ignored-submodules add . and status'  '\n>       +\tcd \"${base_path}\" &&\n>       +\tcd main &&\n>      -+\tGIT_TRACE=1 git add --force . &&\n>      ++\tGIT_TRACE=1 git add --include-ignored-submodules . &&\n>       +\t! git status --porcelain | grep \"^M  sub$\" &&\n>       +\techo\n>       +'\n>      @@ t/t2206-add-submodule-ignored.sh (new)\n>       +'\n>       +\n>       +#8\n>      -+# check that 'git add --force sub' does stage the change in the submodule\n>      -+# check that 'git add --force ./sub/' does stage the change in the submodule\n>      ++# check that 'git add --include-ignored-submodules sub' does stage the change in the submodule\n>      ++# check that 'git add --include-ignored-submodules ./sub/' does stage the change in the submodule\n>       +# and that 'git status --porcelain' does show it as modified\n>       +# commit it..\n>       +# check that 'git log --ignore-submodules=none' shows the submodule change\n>      @@ t/t2206-add-submodule-ignored.sh (new)\n>       +test_expect_success 'main: check force add sub and ./sub/ and status'  '\n>       +\tcd \"${base_path}\" &&\n>       +\tcd main &&\n>      -+\techo \"Adding with --force should work: git add --force sub\" &&\n>      -+\tGIT_TRACE=1 git add --force sub &&\n>      ++\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules sub\" &&\n>      ++\tGIT_TRACE=1 git add --include-ignored-submodules sub &&\n>       +\tgit status --porcelain | grep \"^M  sub$\" &&\n>       +\tgit restore --staged sub &&\n>       +\t! git status --porcelain | grep \"^M  sub$\" &&\n>      -+\techo \"Adding with --force should work: git add --force ./sub/\" &&\n>      -+\tGIT_TRACE=1 git add --force ./sub/ &&\n>      ++\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules ./sub/\" &&\n>      ++\tGIT_TRACE=1 git add --include-ignored-submodules ./sub/ &&\n>       +\tgit status --porcelain | grep \"^M  sub$\" &&\n>       +\tgit commit -m \"update submodule pointer\" &&\n>       +\t! git status --porcelain | grep \"^ M sub$\" &&\n>  4:  58563a7b90 ! 4:  93c95954f1 tests: fix existing tests when add an ignore=all submodule\n>      @@ Metadata\n>        ## Commit message ##\n>           tests: fix existing tests when add an ignore=all submodule\n>       \n>      -    There are tests that rely on \"git add <submodule>\" also adds it. A --force\n>      -    is needed with this enhancement hence they are added accordingly in these\n>      -    tests.\n>      +    There are tests that rely on \"git add <submodule>\" to add updates in the\n>      +    parent repository. A new option --include-ignored-submodules is introduced\n>      +    as it is now needed with this enhancement.\n>       \n>           Updated tests:\n>           - t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n>      +    - t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n>           - t7406-submodule-update.sh\n>           - t7508-status.sh\n>       \n>      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n>        \t\t\tgit push origin modifications\n>        \t\t) &&\n>       -\t\tgit add sub1 &&\n>      -+\t\tgit add --force sub1 &&\n>      ++\t\tgit add --include-ignored-submodules sub1 &&\n>        \t\tgit commit -m \"Modify sub1\" &&\n>        \n>        \t\tgit checkout -b add_nested_sub modify_sub1 &&\n>      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n>        \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n>        \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n>       -\t\tgit add sub1 &&\n>      -+\t\tgit add --force sub1 &&\n>      ++\t\tgit add --include-ignored-submodules sub1 &&\n>        \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n>        \t\tgit checkout -b modify_sub1_recursively &&\n>        \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n>      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n>        \t\tgit -C sub1 add sub2 &&\n>        \t\tgit -C sub1 commit -m \"update nested sub\" &&\n>       -\t\tgit add sub1 &&\n>      -+\t\tgit add --force sub1 &&\n>      ++\t\tgit add --include-ignored-submodules sub1 &&\n>        \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n>        \t\tgit -C sub1 push origin modify_sub1_recursively &&\n>        \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\n>      @@ t/t7508-status.sh: test_expect_success 'git commit will commit a staged but igno\n>        test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n>        \tgit reset HEAD^ &&\n>       -\tgit add sm &&\n>      -+\tgit add --force sm &&\n>      ++\tgit add --include-ignored-submodules sm &&\n>        \tcat >expect << EOF &&\n>        On branch main\n>        Your branch and '\\''upstream'\\'' have diverged,\n>  5:  416695f439 < -:  ---------- Documentation: update add --force and submodule ignore=all config\n>  -:  ---------- > 5:  ee84190cd8 Documentation: add --include_ignored_submodules + ignore=all config\n"},{"id":"530668","messageId":"xmqq1pm1lh7v.fsf@gitster.g","threadId":"64349","inReplyTo":"5796009122c6ab573a2961db598bbd33727a6ac0.1763057433.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/5] read-cache: update add_files_to_cache take param include_ignored_submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-13T22:07:16Z","receivedAt":"2025-11-13T22:07:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Claus Schneider(Eficode) via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n>\n> The include_ignored_submodules parameter is added to the function\n> add_files_to_cache for usage of explicit updating the index for the updated\n> submodule using the explicit patchspec to the submodule.\n>\n> Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> ---\n\nI still do not know enough if the overall idea of this topic is a\ngood idea, but let me regiew the code change at the mechanical level\n(i.e., what needs fixing if these changes are good things to have).\n\n> diff --git a/builtin/add.c b/builtin/add.c\n> index 0235854f80..6d11382f33 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -233,6 +233,7 @@ N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n>  static int verbose, show_only, ignored_too, refresh_only;\n>  static int ignore_add_errors, intent_to_add, ignore_missing;\n>  static int warn_on_embedded_repo = 1;\n> +static int include_ignored_submodules;\n>  \n>  #define ADDREMOVE_DEFAULT 1\n>  static int addremove = ADDREMOVE_DEFAULT;\n> @@ -271,6 +272,7 @@ static struct option builtin_add_options[] = {\n>  \tOPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n>  \tOPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n>  \tOPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n> +    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n\nWrong indentation.  Also, perhaps wrap this new line that is overly\nlong (*WITHOUT* rewrapping existing overly long lines)?\n\n>  \t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n> -\t\t\t\t\t   0);\n> +\t\t\t\t\t   0, 0 );\n\nOur coding style does not allow an extra space after \"(\" or before \")\".\n\n> diff --git a/read-cache-ll.h b/read-cache-ll.h\n> index 71b49d9af4..2c8b4b21b1 100644\n> --- a/read-cache-ll.h\n> +++ b/read-cache-ll.h\n> @@ -481,7 +481,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);\n>  \n>  int add_files_to_cache(struct repository *repo, const char *prefix,\n>  \t\t       const struct pathspec *pathspec, char *ps_matched,\n> -\t\t       int include_sparse, int flags);\n> +\t\t       int include_sparse, int flags, int ignored_too );\n\nI am not sure if adding an extra parameter randomly like this is a\ngood idea.  Existing include_sparse is already a single bit that is\nstuffed in an int, so it might make sense to change it into a set of\nbits (i.e., \"unsigned int\") in one preliminary patch, and then your\nchange can borrow another bit in the same flag word.\n\nSee the attached patch (not even compile tested, though) for an\nillustration of what such a \"preliminary clean-up\" step to get rid\nof the extra include_sparse parameter may look like.\n\n> +++ b/read-cache.c\n> @@ -3880,9 +3880,12 @@ void overlay_tree_on_index(struct index_state *istate,\n>  \n>  struct update_callback_data {\n>  \tstruct index_state *index;\n> +\tstruct repository *repo;\n> +\tstruct pathspec *pathspec;\n>  \tint include_sparse;\n>  \tint flags;\n>  \tint add_errors;\n> +\tint include_ignored_submodules;\n>  };\n>  \n>  static int fix_unmerged_status(struct diff_filepair *p,\n> @@ -3924,7 +3927,48 @@ static void update_callback(struct diff_queue_struct *q,\n>  \t\tdefault:\n>  \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n>  \t\tcase DIFF_STATUS_MODIFIED:\n> -\t\tcase DIFF_STATUS_TYPE_CHANGED:\n> +\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n> +\t\t\tstruct stat st;\n> +\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n\n/* Our single liner comment should look like this, not with double-slashes */\n\nThe fact that this block has to be so deeply indented strongly\nindicates that it should probably become a separate helper function.\n\nI'll stop here for now.\n\n\n\n builtin/add.c      | 8 ++++----\n builtin/checkout.c | 3 +--\n builtin/commit.c   | 2 +-\n read-cache-ll.h    | 6 +++++-\n read-cache.c       | 8 +++-----\n 5 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git c/builtin/add.c w/builtin/add.c\nindex 32709794b3..49d0199c0b 100644\n--- c/builtin/add.c\n+++ w/builtin/add.c\n@@ -384,7 +384,7 @@ int cmd_add(int argc,\n \tint exit_status = 0;\n \tstruct pathspec pathspec;\n \tstruct dir_struct dir = DIR_INIT;\n-\tint flags;\n+\tunsigned flags;\n \tint add_new_files;\n \tint require_pathspec;\n \tchar *seen = NULL;\n@@ -485,7 +485,8 @@ int cmd_add(int argc,\n \t\t (intent_to_add ? ADD_CACHE_INTENT : 0) |\n \t\t (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |\n \t\t (!(addremove || take_worktree_changes)\n-\t\t  ? ADD_CACHE_IGNORE_REMOVAL : 0));\n+\t\t  ? ADD_CACHE_IGNORE_REMOVAL : 0) |\n+\t\t (include_sparse ? ADD_CACHE_INCLUDE_SPARSE : 0));\n \n \tif (repo_read_index_preload(repo, &pathspec, 0) < 0)\n \t\tdie(_(\"index file corrupt\"));\n@@ -583,8 +584,7 @@ int cmd_add(int argc,\n \t\texit_status |= renormalize_tracked_files(repo, &pathspec, flags);\n \telse\n \t\texit_status |= add_files_to_cache(repo, prefix,\n-\t\t\t\t\t\t  &pathspec, ps_matched,\n-\t\t\t\t\t\t  include_sparse, flags);\n+\t\t\t\t\t\t  &pathspec, ps_matched, flags);\n \n \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n \t    report_path_error(ps_matched, &pathspec))\ndiff --git c/builtin/checkout.c w/builtin/checkout.c\nindex f9453473fe..766a8e3b66 100644\n--- c/builtin/checkout.c\n+++ w/builtin/checkout.c\n@@ -898,8 +898,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t\t * entries in the index.\n \t\t\t */\n \n-\t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n-\t\t\t\t\t   0);\n+\t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0);\n \t\t\tinit_ui_merge_options(&o, the_repository);\n \t\t\to.verbosity = 0;\n \t\t\twork = write_in_core_index_as_tree(the_repository);\ndiff --git c/builtin/commit.c w/builtin/commit.c\nindex 0243f17d53..6e42534977 100644\n--- c/builtin/commit.c\n+++ w/builtin/commit.c\n@@ -455,7 +455,7 @@ static const char *prepare_index(const char **argv, const char *prefix,\n \t\trepo_hold_locked_index(the_repository, &index_lock,\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\tadd_files_to_cache(the_repository, also ? prefix : NULL,\n-\t\t\t\t   &pathspec, ps_matched, 0, 0);\n+\t\t\t\t   &pathspec, ps_matched, 0);\n \t\tif (!all && report_path_error(ps_matched, &pathspec))\n \t\t\texit(128);\n \ndiff --git c/read-cache-ll.h w/read-cache-ll.h\nindex 71b49d9af4..c9311f845b 100644\n--- c/read-cache-ll.h\n+++ w/read-cache-ll.h\n@@ -390,11 +390,15 @@ int remove_index_entry_at(struct index_state *, int pos);\n \n void remove_marked_cache_entries(struct index_state *istate, int invalidate);\n int remove_file_from_index(struct index_state *, const char *path);\n+\n+/* add_files_to_cache() flags */\n #define ADD_CACHE_VERBOSE 1\n #define ADD_CACHE_PRETEND 2\n #define ADD_CACHE_IGNORE_ERRORS\t4\n #define ADD_CACHE_IGNORE_REMOVAL 8\n #define ADD_CACHE_INTENT 16\n+#define ADD_CACHE_INCLUDE_SPARSE 32\n+\n /*\n  * These two are used to add the contents of the file at path\n  * to the index, marking the working tree up-to-date by storing\n@@ -481,7 +485,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags);\n+\t\t       unsigned flags);\n \n void overlay_tree_on_index(struct index_state *istate,\n \t\t\t   const char *tree_name, const char *prefix);\ndiff --git c/read-cache.c w/read-cache.c\nindex 032480d0c7..f32b642446 100644\n--- c/read-cache.c\n+++ w/read-cache.c\n@@ -3881,8 +3881,7 @@ void overlay_tree_on_index(struct index_state *istate,\n \n struct update_callback_data {\n \tstruct index_state *index;\n-\tint include_sparse;\n-\tint flags;\n+\tunsigned flags;\n \tint add_errors;\n };\n \n@@ -3917,7 +3916,7 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tstruct diff_filepair *p = q->queue[i];\n \t\tconst char *path = p->one->path;\n \n-\t\tif (!data->include_sparse &&\n+\t\tif (!(data->flags & ADD_CACHE_INCLUDE_SPARSE) &&\n \t\t    !path_in_sparse_checkout(path, data->index))\n \t\t\tcontinue;\n \n@@ -3946,7 +3945,7 @@ static void update_callback(struct diff_queue_struct *q,\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags)\n+\t\t       unsigned flags)\n {\n \tstruct odb_transaction *transaction;\n \tstruct update_callback_data data;\n@@ -3954,7 +3953,6 @@ int add_files_to_cache(struct repository *repo, const char *prefix,\n \n \tmemset(&data, 0, sizeof(data));\n \tdata.index = repo->index;\n-\tdata.include_sparse = include_sparse;\n \tdata.flags = flags;\n \n \trepo_init_revisions(repo, &rev, prefix);\n"},{"id":"530689","messageId":"CA+GP4bob2A+GsVUo5vy+Mw0qJHDD5g+pyo2Ka1726ouUuS_=Wg@mail.gmail.com","threadId":"64349","inReplyTo":"xmqqzf8pln62.fsf@gitster.g","subject":"Re: [PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2025-11-14T13:53:50Z","receivedAt":"2025-11-14T13:54:03Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Thanks Junio - well received and noted. I have updated the PR\ndescription accordingly, but I have not changed the \"--force\" in the\ndescription even though I have implemented\n''--include-ignored-submodules' as Philip had the input not to use\n\"--force\". He suggested using a new option. Philips comment:\n\n> I'm not convinced that the approach of using \"--force\" is a good idea as\n> it conflates ignoring changes to tracked paths (which is what\n> submodule.<name>.ignore\" does) with ignoring untracked paths (which is\n> what \".gitignore\" does). If we're happy to break existing uses that rely\n> on the current behavior then having a new option to override\n> submodule.<name>.ignore strikes me as a better way forward. I don't have\n> much experience of using submodules so I can't comment on whether\n> changing the behavior is a good idea or not.\n\nI think it will be more simple to use the '--force' option though and\nkeep the amount of options lower and less to remember. Given your\ncomments about more usages of bytes for option also becomes obsolete\nif we stick to \"--force\". I am happy to do so.\n\nI am investigating your other comments on the patches in the meantime.\n\nOn Thu, Nov 13, 2025 at 8:58 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Claus Schneider via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > The feature of configuring a submodule to \"ignore=all\" is nicely respected\n> > in commands \"status\" and \"diff\".\n>\n> \"nicely respected\" is not very informative for those who do not know\n> what the setting does.  Saying something like\n>\n>     \"git status\" and \"git diff\" will not report modified submodules\n>     with submodule.<name>.ignore set to \"all\".\n>\n> would not waste significantly more bytes than what you wrote, and is\n> more helpful.\n>\n> > However the \"add\" command does not respect\n> > the configuration the same way.\n>\n> Again, \"does not respect\" and then what?  Running \"git add\" on a\n> submodule with submodule.<name>.ignore set to \"all\" does what?\n> Complains that it has changes but because .ignore is set it won't\n> add?  Adds it silently?  Something else?\n>\n> > The behavior is problematic for the logic\n> > between status/diff and add.\n>\n> After this sentence, \"because ...\" is missing.  Please help readers\n> understand the issue you perceive as problematic more easily.\n>\n> I am guessing that you are assuming that an \"add\", after \"diff\" or\n> \"status\" said there is no change, is expected to be a no-op, but I\n> cannot be sure if that is what you are referring to here with the\n> reason left unsaid like the above.\n>\n> > Secondly it makes it problematic to track\n> > branches in the submodule configuration as developers unintentionally keeps\n> > add submodule updates and get conflicts for no intentional reason. Both adds\n> > unnecessary friction to the usage of submodules.\n> >\n> > The patches implement the same logical behavior for ignore=all submodules as\n> > regular ignored files. The status now does not show any diff - nor will the\n> > add command update the reference submodule reference. If you add the\n> > submodule path which is ignore=all then you are presented with a message\n> > that you need to use the --force option.\n>\n> I vaguely recall that an earlier discussion between you and Phillip\n> were concluding against \"--force\"?  I personally feel it is in line\n> with \"git add foo.o\" (when '*.o' is in .gitignore) gets rejected and\n> \"git add -f foo.o\" is a way to override it, but in the list of\n> patches below, I see --include-ignored-submodules (no, our command\n> line option names do not use underscore for inter-word-gaps), so I\n> suspect the description in the cover letter around here is stale?\n>\n>\n> > The branch=, ignore=all (and\n> > update=none) now works great with update --remote,\n>\n> Again, \"great\" is not very informative, and as bad as \"nicely\n> respected\".  Avoid using these adjectives loaded with unnecessary\n> value judgements, and instead trust your readers.  They are\n> intelligent to judge if the updated behaviour is great or not for\n> themselves.  Try to use the same bytes on helping readers understand\n> what actually happens.\n>\n> > but developers does not\n>\n> \"do not\".\n>\n> > have to consider changes in the updates of the submodule sha1. The\n> > implementation removes a friction of working with submodules and can be used\n> > like the repo tool with branches configured. The submodule status report\n> > could be used for build/release documentation for reproduction of a setup.\n> >\n> > A few tests used the adding of submodules without --force, hence they have\n> > been updated to use the --force option.\n> >\n> > Claus Schneider(Eficode) (5):\n> >   read-cache: update add_files_to_cache take param\n> >     include_ignored_submodules\n> >   read-cache: add/read-cache respect submodule ignore=all\n> >   tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n> >     scenario\n> >   tests: fix existing tests when add an ignore=all submodule\n> >   Documentation: add --include_ignored_submodules + ignore=all config\n> >\n> >  .devcontainer/Dockerfile            |  70 +++++++++++++++\n> >  .devcontainer/Dockerfile.standalone |  76 ++++++++++++++++\n> >  .devcontainer/devcontainer.json     |  25 ++++++\n> >  Documentation/config/submodule.adoc |  13 +--\n> >  Documentation/git-add.adoc          |   5 ++\n> >  Documentation/gitmodules.adoc       |   5 +-\n> >  builtin/add.c                       |   4 +-\n> >  builtin/checkout.c                  |   2 +-\n> >  builtin/commit.c                    |   2 +-\n> >  read-cache-ll.h                     |   2 +-\n> >  read-cache.c                        |  54 ++++++++++-\n> >  t/lib-submodule-update.sh           |   6 +-\n> >  t/meson.build                       |   1 +\n> >  t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++\n> >  t/t7508-status.sh                   |   2 +-\n> >  15 files changed, 384 insertions(+), 17 deletions(-)\n> >  create mode 100644 .devcontainer/Dockerfile\n> >  create mode 100644 .devcontainer/Dockerfile.standalone\n> >  create mode 100644 .devcontainer/devcontainer.json\n> >  create mode 100755 t/t2206-add-submodule-ignored.sh\n> >\n> >\n> > base-commit: 81f86aacc4eb74cdb9c2c8082d36d2070c666045\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v2\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v2\n> > Pull-Request: https://github.com/gitgitgadget/git/pull/1987\n> >\n> > Range-diff vs v1:\n> >\n> >  1:  d98cca698d ! 1:  5796009122 read-cache: update add_files_to_cache to take param ignored_too(--force)\n> >      @@ Metadata\n> >       Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> >\n> >        ## Commit message ##\n> >      -    read-cache: update add_files_to_cache to take param ignored_too(--force)\n> >      +    read-cache: update add_files_to_cache take param include_ignored_submodules\n> >\n> >      -    The ignored_too parameter is added to the function add_files_to_cache for\n> >      -    usage of explicit updating the index for the updated submodule using the\n> >      -    explicit patchspec to the submodule.\n> >      +    The include_ignored_submodules parameter is added to the function\n> >      +    add_files_to_cache for usage of explicit updating the index for the updated\n> >      +    submodule using the explicit patchspec to the submodule.\n> >\n> >           Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> >\n> >        ## builtin/add.c ##\n> >      +@@ builtin/add.c: N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n> >      + static int verbose, show_only, ignored_too, refresh_only;\n> >      + static int ignore_add_errors, intent_to_add, ignore_missing;\n> >      + static int warn_on_embedded_repo = 1;\n> >      ++static int include_ignored_submodules;\n> >      +\n> >      + #define ADDREMOVE_DEFAULT 1\n> >      + static int addremove = ADDREMOVE_DEFAULT;\n> >      +@@ builtin/add.c: static struct option builtin_add_options[] = {\n> >      +        OPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n> >      +        OPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n> >      +        OPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n> >      ++    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n> >      +        OPT_STRING(0, \"chmod\", &chmod_arg, \"(+|-)x\",\n> >      +                   N_(\"override the executable bit of the listed files\")),\n> >      +        OPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n> >       @@ builtin/add.c: int cmd_add(int argc,\n> >               else\n> >                       exit_status |= add_files_to_cache(repo, prefix,\n> >                                                         &pathspec, ps_matched,\n> >       -                                                 include_sparse, flags);\n> >      -+                                                 include_sparse, flags, ignored_too);\n> >      ++                                                 include_sparse, flags, include_ignored_submodules);\n> >\n> >               if (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n> >                   report_path_error(ps_matched, &pathspec))\n> >      @@ read-cache.c: void overlay_tree_on_index(struct index_state *istate,\n> >               int include_sparse;\n> >               int flags;\n> >               int add_errors;\n> >      -+       int ignored_too;\n> >      ++       int include_ignored_submodules;\n> >        };\n> >\n> >        static int fix_unmerged_status(struct diff_filepair *p,\n> >       @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> >      +                default:\n> >      +                        die(_(\"unexpected diff status %c\"), p->status);\n> >      +                case DIFF_STATUS_MODIFIED:\n> >      +-               case DIFF_STATUS_TYPE_CHANGED:\n> >      ++               case DIFF_STATUS_TYPE_CHANGED: {\n> >      ++                       struct stat st;\n> >      ++                       if (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n> >      ++                               const struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n> >      ++                               if (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n> >      ++                                       int pathspec_matches = 0;\n> >      ++                                       char *norm_pathspec = NULL;\n> >      ++                                       int ps_i;\n> >      ++                                       trace_printf(\"ignore=all %s\\n\", path);\n> >      ++                                       trace_printf(\"pathspec %s\\n\",\n> >      ++                                                       (data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n> >      ++                                       /* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n> >      ++                                       if (data->pathspec) {\n> >      ++                                               for (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n> >      ++                                                       const char *m = data->pathspec->items[ps_i].match;\n> >      ++                                                       if (!m)\n> >      ++                                                               continue;\n> >      ++                                                       norm_pathspec = xstrdup(m);\n> >      ++                                                       strip_dir_trailing_slashes(norm_pathspec);\n> >      ++                                                       if (!strcmp(path, norm_pathspec)) {\n> >      ++                                                               pathspec_matches = 1;\n> >      ++                                                               FREE_AND_NULL(norm_pathspec);\n> >      ++                                                               break;\n> >      ++                                                       }\n> >      ++                                                       FREE_AND_NULL(norm_pathspec);\n> >      ++                                               }\n> >      ++                                       }\n> >      ++                                       if (pathspec_matches) {\n> >      ++                                               if (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n> >      ++                                                       trace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n> >      ++                                               } else {\n> >      ++                                                       printf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n> >      ++                                                       printf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n> >      ++                                                       continue;\n> >      ++                                               }\n> >      ++                                       } else {\n> >      ++                                               /* No explicit pathspec match -> skip silently (or with trace). */\n> >      ++                                               trace_printf(\"pathspec does not match %s\\n\", path);\n> >      ++                                               continue;\n> >      ++                                       }\n> >      ++                               }\n> >      ++                       }\n> >      +                        if (add_file_to_index(data->index, path, data->flags)) {\n> >      +                                if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n> >      +                                        die(_(\"updating files failed\"));\n> >      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> >\n> >        int add_files_to_cache(struct repository *repo, const char *prefix,\n> >                              const struct pathspec *pathspec, char *ps_matched,\n> >       -                      int include_sparse, int flags)\n> >      -+                      int include_sparse, int flags, int ignored_too )\n> >      ++                      int include_sparse, int flags, int include_ignored_submodules )\n> >        {\n> >               struct update_callback_data data;\n> >               struct rev_info rev;\n> >      @@ read-cache.c: int add_files_to_cache(struct repository *repo, const char *prefix\n> >               data.include_sparse = include_sparse;\n> >               data.flags = flags;\n> >       +       data.repo = repo;\n> >      -+       data.ignored_too = ignored_too;\n> >      ++       data.include_ignored_submodules = include_ignored_submodules;\n> >       +       data.pathspec = (struct pathspec *)pathspec;\n> >\n> >               repo_init_revisions(repo, &rev, prefix);\n> >  2:  d1b02617e6 ! 2:  9ec79b9a11 read-cache: let read-cache respect submodule ignore=all and --force\n> >      @@ Metadata\n> >       Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> >\n> >        ## Commit message ##\n> >      -    read-cache: let read-cache respect submodule ignore=all and --force\n> >      +    read-cache: add/read-cache respect submodule ignore=all\n> >\n> >      -    Given the submdule configuration is ignore=all then only update the\n> >      -    submdule if the --force option is given and the submodule is explicit\n> >      -    given in the pathspec.\n> >      +    Submodules configured with ignore=all are now skipped during add operations\n> >      +    unless overridden by --include-ignored-submodules and the submodule path is\n> >      +    explicitly specified.\n> >\n> >           A message is printed (like ignored files) guiding the user to use the\n> >      -    --force flag if the user has explicitely want to update the submodule\n> >      -    reference.\n> >      +    --include-ignored-submodules flag if the user has explicitely want to update\n> >      +    the submodule reference.\n> >\n> >           The reason for the change is support submodule branch tracking or\n> >           similar and git status state nothing and git add should not add either.\n> >      @@ Commit message\n> >           the submodule is already tracked.\n> >\n> >           The change opens up a lot of possibilities for submodules to be used\n> >      -    more freely and a like the repo tool. A submodule can be added for many\n> >      +    more freely and simular to the repo tool. A submodule can be added for many\n> >           more reason and loosely coupled dependencies to the super repo which often\n> >           gives the friction of handle the explicit commits and updates without\n> >           the need for tracking the submodule sha1 by sha1.\n> >      @@ read-cache.c\n> >        /* Mask for the name length in ce_flags in the on-disk index */\n> >\n> >       @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> >      -                default:\n> >      -                        die(_(\"unexpected diff status %c\"), p->status);\n> >      -                case DIFF_STATUS_MODIFIED:\n> >      --               case DIFF_STATUS_TYPE_CHANGED:\n> >      -+               case DIFF_STATUS_TYPE_CHANGED: {\n> >      -+                       struct stat st;\n> >      -+                       if (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n> >      -+                               const struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n> >      -+                               if (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n> >      -+                                       int pathspec_matches = 0;\n> >      -+                                       char *norm_pathspec = NULL;\n> >      -+                                       int ps_i;\n> >      -+                                       trace_printf(\"ignore=all %s\\n\", path);\n> >      -+                                       trace_printf(\"pathspec %s\\n\",\n> >      -+                                                       (data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n> >      -+                                       /* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n> >      -+                                       if (data->pathspec) {\n> >      -+                                               for (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n> >      -+                                                       const char *m = data->pathspec->items[ps_i].match;\n> >      -+                                                       if (!m)\n> >      -+                                                               continue;\n> >      -+                                                       norm_pathspec = xstrdup(m);\n> >      -+                                                       strip_dir_trailing_slashes(norm_pathspec);\n> >      -+                                                       if (!strcmp(path, norm_pathspec)) {\n> >      -+                                                               pathspec_matches = 1;\n> >      -+                                                               FREE_AND_NULL(norm_pathspec);\n> >      -+                                                               break;\n> >      -+                                                       }\n> >      -+                                                       FREE_AND_NULL(norm_pathspec);\n> >      -+                                               }\n> >      -+                                       }\n> >      -+                                       if (pathspec_matches) {\n> >      -+                                               if (data->ignored_too && data->ignored_too > 0) {\n> >      -+                                                       trace_printf(\"Forcing add of submodule ignored=all due to --force: %s\\n\", path);\n> >      -+                                               } else {\n> >      -+                                                       printf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n> >      -+                                                       printf(_(\"Use -f if you really want to add them.\") );\n> >      -+                                                       continue;\n> >      -+                                               }\n> >      -+                                       } else {\n> >      -+                                               /* No explicit pathspec match -> skip silently (or with trace). */\n> >      -+                                               trace_printf(\"pathspec does not match %s\\n\", path);\n> >      -+                                               continue;\n> >      -+                                       }\n> >      -+                               }\n> >      -+                       }\n> >      -                        if (add_file_to_index(data->index, path, data->flags)) {\n> >      -                                if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n> >      -                                        die(_(\"updating files failed\"));\n> >      +                                        }\n> >      +                                        if (pathspec_matches) {\n> >      +                                                if (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n> >      +-                                                       trace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n> >      ++                                                       trace_printf(\"Add submodule due to --include_ignored_submodules: %s\\n\", path);\n> >      +                                                } else {\n> >      +                                                        printf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n> >      +                                                        printf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n> >      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> >      +                                                }\n> >      +                                        } else {\n> >      +                                                /* No explicit pathspec match -> skip silently (or with trace). */\n> >      +-                                               trace_printf(\"pathspec does not match %s\\n\", path);\n> >      ++                                               trace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n> >      +                                                continue;\n> >      +                                        }\n> >      +                                }\n> >      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> >                                       data->add_errors++;\n> >                               }\n> >                               break;\n> >  3:  8f3d5f7ec1 ! 3:  399a153b95 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario\n> >      @@ Commit message\n> >           config with ignore=all also behaves as intended with configuration in\n> >           .gitmodules and configuration given on the command line.\n> >\n> >      -    Testfile is added to meson.build for execution.\n> >      +    The usage of --include_ignored_submodules is showcased and tested in the\n> >      +    test suite.\n> >      +\n> >      +    The test file is added to meson.build for execution.\n> >\n> >           Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> >\n> >      @@ t/t2206-add-submodule-ignored.sh (new)\n> >       +# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n> >       +# dealing with submodules that have the ignore=all setting in\n> >       +# .gitmodules. It ensures that changes in such submodules are\n> >      -+# ignored by default, but can be staged with \"git add --force\".\n> >      ++# ignored by default, but can be staged with \"git add --include-ignored-submodules\".\n> >       +\n> >       +# shellcheck disable=SC1091\n> >       +. ./test-lib.sh\n> >      @@ t/t2206-add-submodule-ignored.sh (new)\n> >       +'\n> >       +\n> >       +#6\n> >      -+# check that 'git add --force .' does not stage the change in the submodule\n> >      ++# check that 'git add --include-ignored-submodules .' does not stage the change in the submodule\n> >       +# and that 'git status' does not show it as modified\n> >      -+test_expect_success 'main: check --force add . and status'  '\n> >      ++test_expect_success 'main: check --include-ignored-submodules add . and status'  '\n> >       +       cd \"${base_path}\" &&\n> >       +       cd main &&\n> >      -+       GIT_TRACE=1 git add --force . &&\n> >      ++       GIT_TRACE=1 git add --include-ignored-submodules . &&\n> >       +       ! git status --porcelain | grep \"^M  sub$\" &&\n> >       +       echo\n> >       +'\n> >      @@ t/t2206-add-submodule-ignored.sh (new)\n> >       +'\n> >       +\n> >       +#8\n> >      -+# check that 'git add --force sub' does stage the change in the submodule\n> >      -+# check that 'git add --force ./sub/' does stage the change in the submodule\n> >      ++# check that 'git add --include-ignored-submodules sub' does stage the change in the submodule\n> >      ++# check that 'git add --include-ignored-submodules ./sub/' does stage the change in the submodule\n> >       +# and that 'git status --porcelain' does show it as modified\n> >       +# commit it..\n> >       +# check that 'git log --ignore-submodules=none' shows the submodule change\n> >      @@ t/t2206-add-submodule-ignored.sh (new)\n> >       +test_expect_success 'main: check force add sub and ./sub/ and status'  '\n> >       +       cd \"${base_path}\" &&\n> >       +       cd main &&\n> >      -+       echo \"Adding with --force should work: git add --force sub\" &&\n> >      -+       GIT_TRACE=1 git add --force sub &&\n> >      ++       echo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules sub\" &&\n> >      ++       GIT_TRACE=1 git add --include-ignored-submodules sub &&\n> >       +       git status --porcelain | grep \"^M  sub$\" &&\n> >       +       git restore --staged sub &&\n> >       +       ! git status --porcelain | grep \"^M  sub$\" &&\n> >      -+       echo \"Adding with --force should work: git add --force ./sub/\" &&\n> >      -+       GIT_TRACE=1 git add --force ./sub/ &&\n> >      ++       echo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules ./sub/\" &&\n> >      ++       GIT_TRACE=1 git add --include-ignored-submodules ./sub/ &&\n> >       +       git status --porcelain | grep \"^M  sub$\" &&\n> >       +       git commit -m \"update submodule pointer\" &&\n> >       +       ! git status --porcelain | grep \"^ M sub$\" &&\n> >  4:  58563a7b90 ! 4:  93c95954f1 tests: fix existing tests when add an ignore=all submodule\n> >      @@ Metadata\n> >        ## Commit message ##\n> >           tests: fix existing tests when add an ignore=all submodule\n> >\n> >      -    There are tests that rely on \"git add <submodule>\" also adds it. A --force\n> >      -    is needed with this enhancement hence they are added accordingly in these\n> >      -    tests.\n> >      +    There are tests that rely on \"git add <submodule>\" to add updates in the\n> >      +    parent repository. A new option --include-ignored-submodules is introduced\n> >      +    as it is now needed with this enhancement.\n> >\n> >           Updated tests:\n> >           - t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n> >      +    - t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n> >           - t7406-submodule-update.sh\n> >           - t7508-status.sh\n> >\n> >      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n> >                               git push origin modifications\n> >                       ) &&\n> >       -               git add sub1 &&\n> >      -+               git add --force sub1 &&\n> >      ++               git add --include-ignored-submodules sub1 &&\n> >                       git commit -m \"Modify sub1\" &&\n> >\n> >                       git checkout -b add_nested_sub modify_sub1 &&\n> >      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n> >                       git -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n> >                       git -C sub1 commit -a -m \"add a nested submodule\" &&\n> >       -               git add sub1 &&\n> >      -+               git add --force sub1 &&\n> >      ++               git add --include-ignored-submodules sub1 &&\n> >                       git commit -a -m \"update submodule, that updates a nested submodule\" &&\n> >                       git checkout -b modify_sub1_recursively &&\n> >                       git -C sub1 checkout -b modify_sub1_recursively &&\n> >      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n> >                       git -C sub1 add sub2 &&\n> >                       git -C sub1 commit -m \"update nested sub\" &&\n> >       -               git add sub1 &&\n> >      -+               git add --force sub1 &&\n> >      ++               git add --include-ignored-submodules sub1 &&\n> >                       git commit -m \"update sub1, that updates nested sub\" &&\n> >                       git -C sub1 push origin modify_sub1_recursively &&\n> >                       git -C sub1/sub2 push origin modify_sub1_recursively &&\n> >      @@ t/t7508-status.sh: test_expect_success 'git commit will commit a staged but igno\n> >        test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n> >               git reset HEAD^ &&\n> >       -       git add sm &&\n> >      -+       git add --force sm &&\n> >      ++       git add --include-ignored-submodules sm &&\n> >               cat >expect << EOF &&\n> >        On branch main\n> >        Your branch and '\\''upstream'\\'' have diverged,\n> >  5:  416695f439 < -:  ---------- Documentation: update add --force and submodule ignore=all config\n> >  -:  ---------- > 5:  ee84190cd8 Documentation: add --include_ignored_submodules + ignore=all config\n"},{"id":"533801","messageId":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v2.git.1763057433.gitgitgadget@gmail.com","subject":"[PATCH v3 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used","fromName":"Claus Schneider via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-14T07:47:54Z","receivedAt":"2026-01-14T07:48:03Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"The ignore=all configuration for submodules is currently honored by status\nand diff, but not by add. This inconsistency causes friction when working\nwith submodules:\n\n * Developers unintentionally stage submodule updates, leading to conflicts\n   and unnecessary changes.\n * Tracking branches in submodule configs causes friction as updates to the\n   submodule SHA1 are added without intent.\n\nThis patch aligns git add with the behavior of status and diff:\n\n * Submodules marked ignore=all are skipped by default.\n * Attempting to add such a submodule explicitly now requires --force.\n\nA submodule can frictionless track a branch in the configuration or manually\nswitched to and use update --update --remote without unintentionally add the\nchanges to the super-project.\n\nTests that previously added submodules without --force have been updated\naccordingly. A new test is added to test the behavior of git add with and\nwithout --force.\n\nClaus Schneider(Eficode) (5):\n  read-cache: update add_files_to_cache take param ignored_too\n  read-cache: submodule add need --force given ignore=all configuration\n  tests: t2206-add-submodule-ignored: ignore=all and add --force tests\n  tests: fix existing tests when add an ignore=all submodule\n  Documentation: update add --force option + ignore=all config\n\n Documentation/config/submodule.adoc |  13 +--\n Documentation/git-add.adoc          |   5 +-\n Documentation/gitmodules.adoc       |   5 +-\n builtin/add.c                       |   2 +-\n builtin/checkout.c                  |   2 +-\n builtin/commit.c                    |   2 +-\n read-cache-ll.h                     |   2 +-\n read-cache.c                        |  80 ++++++++++++++++-\n t/lib-submodule-update.sh           |   6 +-\n t/meson.build                       |   1 +\n t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++\n t/t7508-status.sh                   |   2 +-\n 12 files changed, 235 insertions(+), 19 deletions(-)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\n\nbase-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/1987\n\nRange-diff vs v2:\n\n 1:  5796009122 ! 1:  d2b66286c2 read-cache: update add_files_to_cache take param include_ignored_submodules\n     @@ Metadata\n      Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## Commit message ##\n     -    read-cache: update add_files_to_cache take param include_ignored_submodules\n     +    read-cache: update add_files_to_cache take param ignored_too\n      \n     -    The include_ignored_submodules parameter is added to the function\n     +    The ignored_too parameter is added to the function\n          add_files_to_cache for usage of explicit updating the index for the updated\n          submodule using the explicit patchspec to the submodule.\n      \n          Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## builtin/add.c ##\n     -@@ builtin/add.c: N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n     - static int verbose, show_only, ignored_too, refresh_only;\n     - static int ignore_add_errors, intent_to_add, ignore_missing;\n     - static int warn_on_embedded_repo = 1;\n     -+static int include_ignored_submodules;\n     - \n     - #define ADDREMOVE_DEFAULT 1\n     - static int addremove = ADDREMOVE_DEFAULT;\n     -@@ builtin/add.c: static struct option builtin_add_options[] = {\n     - \tOPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n     - \tOPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n     - \tOPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n     -+    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n     - \tOPT_STRING(0, \"chmod\", &chmod_arg, \"(+|-)x\",\n     - \t\t   N_(\"override the executable bit of the listed files\")),\n     - \tOPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n      @@ builtin/add.c: int cmd_add(int argc,\n       \telse\n       \t\texit_status |= add_files_to_cache(repo, prefix,\n       \t\t\t\t\t\t  &pathspec, ps_matched,\n      -\t\t\t\t\t\t  include_sparse, flags);\n     -+\t\t\t\t\t\t  include_sparse, flags, include_ignored_submodules);\n     ++\t\t\t\t\t\t  include_sparse, flags, ignored_too);\n       \n       \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n       \t    report_path_error(ps_matched, &pathspec))\n     @@ builtin/checkout.c: static int merge_working_tree(const struct checkout_opts *op\n       \n       \t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n      -\t\t\t\t\t   0);\n     -+\t\t\t\t\t   0, 0 );\n     ++\t\t\t\t\t0, 0);\n       \t\t\tinit_ui_merge_options(&o, the_repository);\n       \t\t\to.verbosity = 0;\n       \t\t\twork = write_in_core_index_as_tree(the_repository);\n     @@ read-cache.c: void overlay_tree_on_index(struct index_state *istate,\n       \tint include_sparse;\n       \tint flags;\n       \tint add_errors;\n     -+\tint include_ignored_submodules;\n     ++\tint ignored_too;\n       };\n       \n       static int fix_unmerged_status(struct diff_filepair *p,\n     @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n       \t\tcase DIFF_STATUS_MODIFIED:\n      -\t\tcase DIFF_STATUS_TYPE_CHANGED:\n      +\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n     -+\t\t\tstruct stat st;\n     -+\t\t\tif (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n     -+\t\t\t\tconst struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n     -+\t\t\t\tif (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n     -+\t\t\t\t\tint pathspec_matches = 0;\n     -+\t\t\t\t\tchar *norm_pathspec = NULL;\n     -+\t\t\t\t\tint ps_i;\n     -+\t\t\t\t\ttrace_printf(\"ignore=all %s\\n\", path);\n     -+\t\t\t\t\ttrace_printf(\"pathspec %s\\n\",\n     -+\t\t\t\t\t\t\t(data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n     -+\t\t\t\t\t/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n     -+\t\t\t\t\tif (data->pathspec) {\n     -+\t\t\t\t\t\tfor (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n     -+\t\t\t\t\t\t\tconst char *m = data->pathspec->items[ps_i].match;\n     -+\t\t\t\t\t\t\tif (!m)\n     -+\t\t\t\t\t\t\t\tcontinue;\n     -+\t\t\t\t\t\t\tnorm_pathspec = xstrdup(m);\n     -+\t\t\t\t\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n     -+\t\t\t\t\t\t\tif (!strcmp(path, norm_pathspec)) {\n     -+\t\t\t\t\t\t\t\tpathspec_matches = 1;\n     -+\t\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     -+\t\t\t\t\t\t\t\tbreak;\n     -+\t\t\t\t\t\t\t}\n     -+\t\t\t\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     -+\t\t\t\t\t\t}\n     -+\t\t\t\t\t}\n     -+\t\t\t\t\tif (pathspec_matches) {\n     -+\t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n     -+\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n     -+\t\t\t\t\t\t} else {\n     -+\t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n     -+\t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n     -+\t\t\t\t\t\t\tcontinue;\n     -+\t\t\t\t\t\t}\n     -+\t\t\t\t\t} else {\n     -+\t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n     -+\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n     -+\t\t\t\t\t\tcontinue;\n     -+\t\t\t\t\t}\n     -+\t\t\t\t}\n     -+\t\t\t}\n       \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n       \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n       \t\t\t\t\tdie(_(\"updating files failed\"));\n     @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n       int add_files_to_cache(struct repository *repo, const char *prefix,\n       \t\t       const struct pathspec *pathspec, char *ps_matched,\n      -\t\t       int include_sparse, int flags)\n     -+\t\t       int include_sparse, int flags, int include_ignored_submodules )\n     ++\t\t       int include_sparse, int flags, int ignored_too )\n       {\n     + \tstruct odb_transaction *transaction;\n       \tstruct update_callback_data data;\n     - \tstruct rev_info rev;\n      @@ read-cache.c: int add_files_to_cache(struct repository *repo, const char *prefix,\n       \tdata.index = repo->index;\n       \tdata.include_sparse = include_sparse;\n       \tdata.flags = flags;\n      +\tdata.repo = repo;\n     -+\tdata.include_ignored_submodules = include_ignored_submodules;\n     ++\tdata.ignored_too = ignored_too;\n      +\tdata.pathspec = (struct pathspec *)pathspec;\n       \n       \trepo_init_revisions(repo, &rev, prefix);\n 2:  9ec79b9a11 ! 2:  de72bf0a91 read-cache: add/read-cache respect submodule ignore=all\n     @@ Metadata\n      Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## Commit message ##\n     -    read-cache: add/read-cache respect submodule ignore=all\n     +    read-cache: submodule add need --force given ignore=all configuration\n      \n          Submodules configured with ignore=all are now skipped during add operations\n     -    unless overridden by --include-ignored-submodules and the submodule path is\n     -    explicitly specified.\n     +    unless overridden by --force and the submodule path is explicitly specified.\n      \n          A message is printed (like ignored files) guiding the user to use the\n     -    --include-ignored-submodules flag if the user has explicitely want to update\n     -    the submodule reference.\n     +    --force flag if the user has explicitely want to update the submodule\n     +    reference.\n      \n          The reason for the change is support submodule branch tracking or\n     -    similar and git status state nothing and git add should not add either.\n     -    The workflow is more logic and similar to regular ignored files even\n     -    the submodule is already tracked.\n     +    similar and git status states nothing and git add should not add either\n     +    as a default behaviour. The workflow is more logic and similar to regular\n     +    ignored files even the submodule is already tracked.\n      \n          The change opens up a lot of possibilities for submodules to be used\n          more freely and simular to the repo tool. A submodule can be added for many\n     @@ read-cache.c\n       #include \"hook.h\"\n      +#include \"submodule.h\"\n      +#include \"submodule-config.h\"\n     ++#include \"advice.h\"\n       \n       /* Mask for the name length in ce_flags in the on-disk index */\n       \n     -@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     - \t\t\t\t\t}\n     - \t\t\t\t\tif (pathspec_matches) {\n     - \t\t\t\t\t\tif (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n     --\t\t\t\t\t\t\ttrace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n     -+\t\t\t\t\t\t\ttrace_printf(\"Add submodule due to --include_ignored_submodules: %s\\n\", path);\n     - \t\t\t\t\t\t} else {\n     - \t\t\t\t\t\t\tprintf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n     - \t\t\t\t\t\t\tprintf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n     -@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     - \t\t\t\t\t\t}\n     - \t\t\t\t\t} else {\n     - \t\t\t\t\t\t/* No explicit pathspec match -> skip silently (or with trace). */\n     --\t\t\t\t\t\ttrace_printf(\"pathspec does not match %s\\n\", path);\n     -+\t\t\t\t\t\ttrace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n     - \t\t\t\t\t\tcontinue;\n     - \t\t\t\t\t}\n     - \t\t\t\t}\n     -@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     - \t\t\t\tdata->add_errors++;\n     - \t\t\t}\n     - \t\t\tbreak;\n     +@@ read-cache.c: static int fix_unmerged_status(struct diff_filepair *p,\n     + \t\treturn DIFF_STATUS_MODIFIED;\n     + }\n     + \n     ++static int skip_submodule(const char *path,\n     ++\t\t\t\t\t\tstruct repository *repo,\n     ++\t\t\t\t\t\tstruct pathspec *pathspec,\n     ++\t\t\t\t\t\tint ignored_too)\n     ++{\n     ++    struct stat st;\n     ++    const struct submodule *sub;\n     ++    int pathspec_matches = 0;\n     ++    int ps_i;\n     ++    char *norm_pathspec = NULL;\n     ++\n     ++    /* Only consider if path is a directory */\n     ++    if (lstat(path, &st) || !S_ISDIR(st.st_mode))\n     ++\t\treturn 0;\n     ++\n     ++    /* Check if it's a submodule with ignore=all */\n     ++    sub = submodule_from_path(repo, null_oid(the_hash_algo), path);\n     ++    if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, \"all\"))\n     ++\t\treturn 0;\n     ++\n     ++    trace_printf(\"ignore=all: %s\\n\", path);\n     ++    trace_printf(\"pathspec %s\\n\", (pathspec && pathspec->nr)\n     ++\t\t\t\t\t\t\t\t\t? \"has pathspec\"\n     ++\t\t\t\t\t\t\t\t\t: \"no pathspec\");\n     ++\n     ++    /* Check if submodule path is explicitly mentioned in pathspec */\n     ++    if (pathspec) {\n     ++\t\tfor (ps_i = 0; ps_i < pathspec->nr; ps_i++) {\n     ++\t\t\tconst char *m = pathspec->items[ps_i].match;\n     ++\t\t\tif (!m)\n     ++\t\t\t\tcontinue;\n     ++\t\t\tnorm_pathspec = xstrdup(m);\n     ++\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n     ++\t\t\tif (!strcmp(path, norm_pathspec)) {\n     ++\t\t\t\tpathspec_matches = 1;\n     ++\t\t\t\tFREE_AND_NULL(norm_pathspec);\n     ++\t\t\t\tbreak;\n     ++\t\t\t}\n     ++\t\t\tFREE_AND_NULL(norm_pathspec);\n      +\t\t}\n     - \t\tcase DIFF_STATUS_DELETED:\n     - \t\t\tif (data->flags & ADD_CACHE_IGNORE_REMOVAL)\n     - \t\t\t\tbreak;\n     ++    }\n     ++\n     ++    /* If explicitly matched and forced, allow adding */\n     ++    if (pathspec_matches) {\n     ++\t\tif (ignored_too && ignored_too > 0) {\n     ++\t\t\ttrace_printf(\"Add submodule due to --force: %s\\n\", path);\n     ++\t\t\treturn 0;\n     ++\t\t} else {\n     ++\t\t\tadvise_if_enabled(ADVICE_ADD_IGNORED_FILE,\n     ++\t\t\t\t_(\"Skipping submodule due to ignore=all: %s\\n\"\n     ++\t\t\t\t\t\"Use --force if you really want to add the submodule.\"), path);\n     ++\t\t\treturn 1;\n     ++\t\t}\n     ++    }\n     ++\n     ++    /* No explicit pathspec match -> skip silently */\n     ++    trace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n     ++    return 1;\n     ++}\n     ++\n     + static void update_callback(struct diff_queue_struct *q,\n     +-\t\t\t    struct diff_options *opt UNUSED, void *cbdata)\n     ++\t\t\t\t\t\t\tstruct diff_options *opt UNUSED, void *cbdata)\n     + {\n     + \tint i;\n     + \tstruct update_callback_data *data = cbdata;\n     +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n     + \t\tconst char *path = p->one->path;\n     + \n     + \t\tif (!data->include_sparse &&\n     +-\t\t    !path_in_sparse_checkout(path, data->index))\n     ++\t\t\t!path_in_sparse_checkout(path, data->index))\n     + \t\t\tcontinue;\n     + \n     + \t\tswitch (fix_unmerged_status(p, data)) {\n     + \t\tdefault:\n     + \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n     + \t\tcase DIFF_STATUS_MODIFIED:\n     +-\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n     ++\t\tcase DIFF_STATUS_TYPE_CHANGED:\n     ++\t\t\tif (skip_submodule(path, data->repo,\n     ++\t\t\t\t\t\t\t\tdata->pathspec,\n     ++\t\t\t\t\t\t\t\tdata->ignored_too))\n     ++\t\t\t\tcontinue;\n     ++\n     + \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n     + \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n     + \t\t\t\t\tdie(_(\"updating files failed\"));\n 3:  399a153b95 ! 3:  d7b97e12d3 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario\n     @@ Metadata\n      Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## Commit message ##\n     -    tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario\n     +    tests: t2206-add-submodule-ignored: ignore=all and add --force tests\n      \n          The tests verify that the submodule behavior is intact and updating the\n          config with ignore=all also behaves as intended with configuration in\n          .gitmodules and configuration given on the command line.\n      \n     -    The usage of --include_ignored_submodules is showcased and tested in the\n     -    test suite.\n     +    The usage of --force is showcased and tested in the test suite.\n      \n          The test file is added to meson.build for execution.\n      \n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n      +# dealing with submodules that have the ignore=all setting in\n      +# .gitmodules. It ensures that changes in such submodules are\n     -+# ignored by default, but can be staged with \"git add --include-ignored-submodules\".\n     ++# ignored by default, but can be staged with \"git add --force\".\n      +\n      +# shellcheck disable=SC1091\n      +. ./test-lib.sh\n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +'\n      +\n      +#6\n     -+# check that 'git add --include-ignored-submodules .' does not stage the change in the submodule\n     ++# check that 'git add --force .' does not stage the change in the submodule\n      +# and that 'git status' does not show it as modified\n     -+test_expect_success 'main: check --include-ignored-submodules add . and status'  '\n     ++test_expect_success 'main: check --force add . and status'  '\n      +\tcd \"${base_path}\" &&\n      +\tcd main &&\n     -+\tGIT_TRACE=1 git add --include-ignored-submodules . &&\n     ++\tGIT_TRACE=1 git add --force . &&\n      +\t! git status --porcelain | grep \"^M  sub$\" &&\n      +\techo\n      +'\n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +test_expect_success 'main: check _add sub_ and status'  '\n      +\tcd \"${base_path}\" &&\n      +\tcd main &&\n     -+\tGIT_TRACE=1 git add sub | grep \"Skipping submodule due to ignore=all: sub\" &&\n     ++\tGIT_TRACE=1 git add sub 2>&1 | grep \"Skipping submodule due to ignore=all: sub\" &&\n      +\t! git status --porcelain | grep \"^M  sub$\" &&\n      +\techo\n      +'\n      +\n      +#8\n     -+# check that 'git add --include-ignored-submodules sub' does stage the change in the submodule\n     -+# check that 'git add --include-ignored-submodules ./sub/' does stage the change in the submodule\n     ++# check that 'git add --force sub' does stage the change in the submodule\n     ++# check that 'git add --force ./sub/' does stage the change in the submodule\n      +# and that 'git status --porcelain' does show it as modified\n      +# commit it..\n      +# check that 'git log --ignore-submodules=none' shows the submodule change\n     @@ t/t2206-add-submodule-ignored.sh (new)\n      +test_expect_success 'main: check force add sub and ./sub/ and status'  '\n      +\tcd \"${base_path}\" &&\n      +\tcd main &&\n     -+\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules sub\" &&\n     -+\tGIT_TRACE=1 git add --include-ignored-submodules sub &&\n     ++\techo \"Adding with --force should work: git add --force sub\" &&\n     ++\tGIT_TRACE=1 git add --force sub &&\n      +\tgit status --porcelain | grep \"^M  sub$\" &&\n      +\tgit restore --staged sub &&\n      +\t! git status --porcelain | grep \"^M  sub$\" &&\n     -+\techo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules ./sub/\" &&\n     -+\tGIT_TRACE=1 git add --include-ignored-submodules ./sub/ &&\n     ++\techo \"Adding with --force should work: git add --force ./sub/\" &&\n     ++\tGIT_TRACE=1 git add --force ./sub/ &&\n      +\tgit status --porcelain | grep \"^M  sub$\" &&\n      +\tgit commit -m \"update submodule pointer\" &&\n      +\t! git status --porcelain | grep \"^ M sub$\" &&\n 4:  93c95954f1 ! 4:  6e44ab6804 tests: fix existing tests when add an ignore=all submodule\n     @@ Metadata\n       ## Commit message ##\n          tests: fix existing tests when add an ignore=all submodule\n      \n     -    There are tests that rely on \"git add <submodule>\" to add updates in the\n     -    parent repository. A new option --include-ignored-submodules is introduced\n     -    as it is now needed with this enhancement.\n     +    There are tests that rely on \"git add <submodule>\" to update the in the\n     +    reference in the parent repository which have been updated to use the\n     +    --force option.\n      \n          Updated tests:\n          - t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n     @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n       \t\t\tgit push origin modifications\n       \t\t) &&\n      -\t\tgit add sub1 &&\n     -+\t\tgit add --include-ignored-submodules sub1 &&\n     ++\t\tgit add --force sub1 &&\n       \t\tgit commit -m \"Modify sub1\" &&\n       \n       \t\tgit checkout -b add_nested_sub modify_sub1 &&\n     @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n       \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n       \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n      -\t\tgit add sub1 &&\n     -+\t\tgit add --include-ignored-submodules sub1 &&\n     ++\t\tgit add --force sub1 &&\n       \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n       \t\tgit checkout -b modify_sub1_recursively &&\n       \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n     @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n       \t\tgit -C sub1 add sub2 &&\n       \t\tgit -C sub1 commit -m \"update nested sub\" &&\n      -\t\tgit add sub1 &&\n     -+\t\tgit add --include-ignored-submodules sub1 &&\n     ++\t\tgit add --force sub1 &&\n       \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n       \t\tgit -C sub1 push origin modify_sub1_recursively &&\n       \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\n     @@ t/t7508-status.sh: test_expect_success 'git commit will commit a staged but igno\n       test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n       \tgit reset HEAD^ &&\n      -\tgit add sm &&\n     -+\tgit add --include-ignored-submodules sm &&\n     ++\tgit add --force sm &&\n       \tcat >expect << EOF &&\n       On branch main\n       Your branch and '\\''upstream'\\'' have diverged,\n 5:  ee84190cd8 ! 5:  37fe7956e0 Documentation: add --include_ignored_submodules + ignore=all config\n     @@ Metadata\n      Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n       ## Commit message ##\n     -    Documentation: add --include_ignored_submodules + ignore=all config\n     +    Documentation: update add --force option + ignore=all config\n      \n     -    - git-add.adoc: Add new documentation for --include_ignored_submodules\n     -      option to supress ignore=all and new submodule functionality of not\n     -      adding a ignore=all submodule by default.\n     +    - git-add.adoc: Update the --force documentation for submodule behaviour\n     +      to be added even the given configuration ignore=all.\n          - gitmodules.adoc and config/submodule.adoc: The submodule config\n     -      ignore=all now need --include_ignored_submodules in order to update\n     -      the index.\n     +      ignore=all now need --force in order to update the index.\n      \n          Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n     - ## .devcontainer/Dockerfile (new) ##\n     -@@\n     -+FROM ubuntu:latest\n     -+\n     -+ARG USER_ID\n     -+ARG GROUP_ID\n     -+\n     -+ENV DEBIAN_FRONTEND=noninteractive\n     -+ENV TZ=Europe/Copenhagen\n     -+\n     -+RUN apt-get update \\\n     -+    && \\\n     -+    apt-get install -y \\\n     -+        sudo \\\n     -+        build-essential \\\n     -+        libcurl4-gnutls-dev \\\n     -+        libexpat1-dev \\\n     -+        gettext \\\n     -+        libz-dev \\\n     -+        libssl-dev \\\n     -+        asciidoc \\\n     -+        xmlto \\\n     -+        docbook-xsl \\\n     -+        \\\n     -+        tzdata \\\n     -+        git \\\n     -+        coccinelle \\\n     -+    && \\\n     -+    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \\\n     -+    && \\\n     -+    dpkg-reconfigure --frontend noninteractive tzdata\n     -+\n     -+RUN  apt-get update && apt-get install -y autoconf\n     -+\n     -+RUN addgroup -gid 1001 gituser\n     -+RUN adduser --disabled-password -u 1001 -gid 1001 gituser\n     -+RUN usermod -aG sudo gituser\n     -+RUN echo 'gituser ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/010-gituser\n     -+RUN chmod 0440 /etc/sudoers.d/010-gituser\n     -+\n     -+USER 1001\n     -+\n     -+#WORKDIR /home/gituser/git-src/\n     -+\n     -+#RUN  make configure\n     -+#RUN ./configure --prefix=${HOME}/.local/\n     -+\n     -+#RUN make -j$(nproc) gitweb || make gitweb \n     -+#RUN make install-gitweb\n     -+\n     -+#RUN make -j$(nproc) || make\n     -+#RUN make -j$(nproc) gitweb || make gitweb \n     -+#RUN make install-gitweb\n     -+#RUN make -j$(nproc) NO_PERL=YesPlease install || make NO_PERL=YesPlease install\n     -+#RUN make install\n     -+\n     -+\n     -+RUN mkdir -p  ${HOME}/.local/\n     -+#RUN ls -la ${HOME}/.local/bin\n     -+#ENV PATH=\"/home/gituser/.local/bin:${PATH}\"\n     -+#RUN ls -l $HOME/.local/bin\n     -+#RUN echo $PATH $HOME \n     -+\n     -+#RUN git --version\n     -+#RUN which git \n     -+\n     -+RUN git config --global user.email \"gituser@example.com\"\n     -+RUN git config --global user.name \"Git User\"\n     -+\n     -+#WORKDIR /home/gituser/git-test/\n     -+\n     -+#CMD [ \"git\" ]\n     -\n     - ## .devcontainer/Dockerfile.standalone (new) ##\n     -@@\n     -+FROM ubuntu:latest\n     -+\n     -+ARG USER_ID\n     -+ARG GROUP_ID\n     -+\n     -+ENV DEBIAN_FRONTEND=noninteractive\n     -+ENV TZ=Europe/Copenhagen\n     -+\n     -+RUN apt-get update \\\n     -+    && \\\n     -+    apt-get install -y \\\n     -+        build-essential \\\n     -+        libcurl4-gnutls-dev \\\n     -+        libexpat1-dev \\\n     -+        gettext \\\n     -+        libz-dev \\\n     -+        libssl-dev \\\n     -+        asciidoc \\\n     -+        xmlto \\\n     -+        docbook-xsl \\\n     -+        \\\n     -+        tzdata \\\n     -+        \\\n     -+        nano \\\n     -+        vim \\\n     -+    && \\\n     -+    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime \\\n     -+    && \\\n     -+    dpkg-reconfigure --frontend noninteractive tzdata\n     -+\n     -+RUN  apt-get update && apt-get install -y autoconf\n     -+\n     -+RUN addgroup -gid ${GROUP_ID} gituser\n     -+RUN adduser --disabled-password -u ${USER_ID} -gid ${GROUP_ID} gituser\n     -+\n     -+\n     -+COPY --chown=${USER_ID}:${GROUP_ID} ./git /home/gituser/git-src/\n     -+\n     -+USER ${USER_ID}\n     -+\n     -+WORKDIR /home/gituser/git-src/\n     -+\n     -+RUN  make configure\n     -+RUN ./configure --prefix=${HOME}/.local/\n     -+\n     -+#RUN make -j$(nproc) gitweb || make gitweb \n     -+#RUN make install-gitweb\n     -+\n     -+#RUN make -j$(nproc) || make\n     -+#RUN make -j$(nproc) gitweb || make gitweb \n     -+#RUN make install-gitweb\n     -+RUN make -j$(nproc) NO_PERL=YesPlease install || make NO_PERL=YesPlease install\n     -+RUN make install\n     -+\n     -+WORKDIR /home/gituser/git-src/t\n     -+RUN ./t2206-add-submodule-ignored.sh -v\n     -+\n     -+RUN ls -la ${HOME}/.local/\n     -+RUN ls -la ${HOME}/.local/bin\n     -+ENV PATH=\"/home/gituser/.local/bin:${PATH}\"\n     -+RUN ls -l $HOME/.local/bin\n     -+RUN echo $PATH $HOME \n     -+\n     -+RUN git --version\n     -+RUN which git \n     -+\n     -+RUN git config --global user.email \"gituser@example.com\"\n     -+RUN git config --global user.name \"Git User\"\n     -+\n     -+WORKDIR /home/gituser/git-src/t\n     -+RUN pwd && ls -la \n     -+RUN ./t2206-add-submodule-ignored.sh -v\n     -+\n     -+WORKDIR /home/gituser/git-test/\n     -+\n     -+CMD [ \"git\" ]\n     -\n     - ## .devcontainer/devcontainer.json (new) ##\n     -@@\n     -+{\n     -+  \"name\": \"Git Dev Container\",\n     -+  \"build\": {\n     -+    \"dockerfile\": \"Dockerfile\",\n     -+    \"context\": \"\",\n     -+    \"args\": {\n     -+      \"user_id\": \"1001\",\n     -+      \"group_id\": \"1001\"\n     -+    }\n     -+  },\n     -+  \"customizations\": {\n     -+    \"vscode\": {\n     -+      \"settings\": {\n     -+        \"terminal.integrated.shell.linux\": \"/bin/bash\"\n     -+      }\n     -+    }\n     -+  },\n     -+  \"remoteUser\": \"gituser\",\n     -+  \"features\": {},\n     -+  \"mounts\": [\n     -+    \"source=${localWorkspaceFolder}/,target=/home/gitusers/git-src,type=bind,consistency=cached\",\n     -+    \"source=${localWorkspaceFolder}/,target=/home/gitusers/git-test,type=bind,consistency=cached\"\n     -+  ],\n     -+  \"postCreateCommand\": \"echo\"\n     -+}\n     -\n       ## Documentation/config/submodule.adoc ##\n      @@ Documentation/config/submodule.adoc: submodule.<name>.fetchRecurseSubmodules::\n       \n     @@ Documentation/config/submodule.adoc: submodule.<name>.fetchRecurseSubmodules::\n      -\tcommit when it has been staged), \"dirty\" will ignore all changes\n      -\tto the submodule's work tree and\n      +\ta submodule as modified.\n     -+\tSet to \"all\" will never considered the submodule modified. It can\n     -+\tnevertheless be staged using the option --include_ignored_submodules and\n     -+\tit will then show up in the output of status.\n     ++\tSet to \"all\" will never consider the submodule modified. It can\n     ++\tnevertheless be staged using the option --force and it will then show up\n     ++\tin the output of status.\n      +\tSet to \"dirty\" will ignore all changes to the submodule's work tree and\n       \ttakes only differences between the HEAD of the submodule and the commit\n       \trecorded in the superproject into account. \"untracked\" will additionally\n     @@ Documentation/config/submodule.adoc: submodule.<name>.fetchRecurseSubmodules::\n      \n       ## Documentation/git-add.adoc ##\n      @@ Documentation/git-add.adoc: in linkgit:gitglossary[7].\n     + \n     + `-f`::\n       `--force`::\n     - \tAllow adding otherwise ignored files.\n     +-\tAllow adding otherwise ignored files.\n     ++\tAllow adding otherwise ignored files. The option is also used when\n     ++\t`submodule.<name>.ignore=all` is set, but you want to stage an\n     ++\tupdate of the submodule. The `path` to the submodule must be explicitly\n     ++\tspecified.\n       \n     -+`--include_ignored_submodules`::\n     -+\tThe option is also used when `submodule.<name>.ignore=all`\n     -+\tis set, but you want to stage an update of the submodule. The\n     -+\t`path` to the submodule must be explicitly specified.\n     -+\n       `--sparse`::\n       \tAllow updating index entries outside of the sparse-checkout cone.\n     - \tNormally, `git add` refuses to update index entries whose paths do\n      \n       ## Documentation/gitmodules.adoc ##\n      @@ Documentation/gitmodules.adoc: submodule.<name>.ignore::\n     @@ Documentation/gitmodules.adoc: submodule.<name>.ignore::\n       \t    nonetheless show up in the output of status and commit when it has\n      -\t    been staged).\n      +\t    been staged). Add `(new commits)` can be overruled using the\n     -+\t    `git add --include_ignored_submodules <submodule.path>` \n     -+\t\tThe setting affects `status`, `update-index`, `diff` and `log`(due \n     ++\t    `git add --force <submodule.path>`.\n     ++\t\tThe setting affects `status`, `update-index`, `diff` and `log`(due\n      +\t\tto underlaying `diff`).\n       \n       \tdirty;; All changes to the submodule's work tree will be ignored, only\n\n-- \ngitgitgadget\n"},{"id":"533800","messageId":"d2b66286c23b5736949610c89b4d51e025307845.1768376879.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","subject":"[PATCH v3 1/5] read-cache: update add_files_to_cache take param ignored_too","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-14T07:47:55Z","receivedAt":"2026-01-14T07:48:04Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe ignored_too parameter is added to the function\nadd_files_to_cache for usage of explicit updating the index for the updated\nsubmodule using the explicit patchspec to the submodule.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n builtin/add.c      |  2 +-\n builtin/checkout.c |  2 +-\n builtin/commit.c   |  2 +-\n read-cache-ll.h    |  2 +-\n read-cache.c       | 10 ++++++++--\n 5 files changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 32709794b3..eef4959ee3 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -584,7 +584,7 @@ int cmd_add(int argc,\n \telse\n \t\texit_status |= add_files_to_cache(repo, prefix,\n \t\t\t\t\t\t  &pathspec, ps_matched,\n-\t\t\t\t\t\t  include_sparse, flags);\n+\t\t\t\t\t\t  include_sparse, flags, ignored_too);\n \n \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n \t    report_path_error(ps_matched, &pathspec))\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex f9453473fe..88d6a68022 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -899,7 +899,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t\t */\n \n \t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n-\t\t\t\t\t   0);\n+\t\t\t\t\t0, 0);\n \t\t\tinit_ui_merge_options(&o, the_repository);\n \t\t\to.verbosity = 0;\n \t\t\twork = write_in_core_index_as_tree(the_repository);\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 0243f17d53..1a00642090 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -455,7 +455,7 @@ static const char *prepare_index(const char **argv, const char *prefix,\n \t\trepo_hold_locked_index(the_repository, &index_lock,\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\tadd_files_to_cache(the_repository, also ? prefix : NULL,\n-\t\t\t\t   &pathspec, ps_matched, 0, 0);\n+\t\t\t\t   &pathspec, ps_matched, 0, 0, 0 );\n \t\tif (!all && report_path_error(ps_matched, &pathspec))\n \t\t\texit(128);\n \ndiff --git a/read-cache-ll.h b/read-cache-ll.h\nindex 71b49d9af4..2c8b4b21b1 100644\n--- a/read-cache-ll.h\n+++ b/read-cache-ll.h\n@@ -481,7 +481,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags);\n+\t\t       int include_sparse, int flags, int ignored_too );\n \n void overlay_tree_on_index(struct index_state *istate,\n \t\t\t   const char *tree_name, const char *prefix);\ndiff --git a/read-cache.c b/read-cache.c\nindex 032480d0c7..0f4981d79f 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3881,9 +3881,12 @@ void overlay_tree_on_index(struct index_state *istate,\n \n struct update_callback_data {\n \tstruct index_state *index;\n+\tstruct repository *repo;\n+\tstruct pathspec *pathspec;\n \tint include_sparse;\n \tint flags;\n \tint add_errors;\n+\tint ignored_too;\n };\n \n static int fix_unmerged_status(struct diff_filepair *p,\n@@ -3925,7 +3928,7 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tdefault:\n \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n \t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n \t\t\t\t\tdie(_(\"updating files failed\"));\n@@ -3946,7 +3949,7 @@ static void update_callback(struct diff_queue_struct *q,\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags)\n+\t\t       int include_sparse, int flags, int ignored_too )\n {\n \tstruct odb_transaction *transaction;\n \tstruct update_callback_data data;\n@@ -3956,6 +3959,9 @@ int add_files_to_cache(struct repository *repo, const char *prefix,\n \tdata.index = repo->index;\n \tdata.include_sparse = include_sparse;\n \tdata.flags = flags;\n+\tdata.repo = repo;\n+\tdata.ignored_too = ignored_too;\n+\tdata.pathspec = (struct pathspec *)pathspec;\n \n \trepo_init_revisions(repo, &rev, prefix);\n \tsetup_revisions(0, NULL, &rev, NULL);\n-- \ngitgitgadget\n\n"},{"id":"533803","messageId":"de72bf0a9135224ed4c4a05ae00deadc28225ac0.1768376879.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","subject":"[PATCH v3 2/5] read-cache: submodule add need --force given ignore=all configuration","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-14T07:47:56Z","receivedAt":"2026-01-14T07:48:07Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nSubmodules configured with ignore=all are now skipped during add operations\nunless overridden by --force and the submodule path is explicitly specified.\n\nA message is printed (like ignored files) guiding the user to use the\n--force flag if the user has explicitely want to update the submodule\nreference.\n\nThe reason for the change is support submodule branch tracking or\nsimilar and git status states nothing and git add should not add either\nas a default behaviour. The workflow is more logic and similar to regular\nignored files even the submodule is already tracked.\n\nThe change opens up a lot of possibilities for submodules to be used\nmore freely and simular to the repo tool. A submodule can be added for many\nmore reason and loosely coupled dependencies to the super repo which often\ngives the friction of handle the explicit commits and updates without\nthe need for tracking the submodule sha1 by sha1.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n read-cache.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 71 insertions(+), 3 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 0f4981d79f..cc79b25f43 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -47,6 +47,9 @@\n #include \"csum-file.h\"\n #include \"promisor-remote.h\"\n #include \"hook.h\"\n+#include \"submodule.h\"\n+#include \"submodule-config.h\"\n+#include \"advice.h\"\n \n /* Mask for the name length in ce_flags in the on-disk index */\n \n@@ -3910,8 +3913,68 @@ static int fix_unmerged_status(struct diff_filepair *p,\n \t\treturn DIFF_STATUS_MODIFIED;\n }\n \n+static int skip_submodule(const char *path,\n+\t\t\t\t\t\tstruct repository *repo,\n+\t\t\t\t\t\tstruct pathspec *pathspec,\n+\t\t\t\t\t\tint ignored_too)\n+{\n+    struct stat st;\n+    const struct submodule *sub;\n+    int pathspec_matches = 0;\n+    int ps_i;\n+    char *norm_pathspec = NULL;\n+\n+    /* Only consider if path is a directory */\n+    if (lstat(path, &st) || !S_ISDIR(st.st_mode))\n+\t\treturn 0;\n+\n+    /* Check if it's a submodule with ignore=all */\n+    sub = submodule_from_path(repo, null_oid(the_hash_algo), path);\n+    if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, \"all\"))\n+\t\treturn 0;\n+\n+    trace_printf(\"ignore=all: %s\\n\", path);\n+    trace_printf(\"pathspec %s\\n\", (pathspec && pathspec->nr)\n+\t\t\t\t\t\t\t\t\t? \"has pathspec\"\n+\t\t\t\t\t\t\t\t\t: \"no pathspec\");\n+\n+    /* Check if submodule path is explicitly mentioned in pathspec */\n+    if (pathspec) {\n+\t\tfor (ps_i = 0; ps_i < pathspec->nr; ps_i++) {\n+\t\t\tconst char *m = pathspec->items[ps_i].match;\n+\t\t\tif (!m)\n+\t\t\t\tcontinue;\n+\t\t\tnorm_pathspec = xstrdup(m);\n+\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n+\t\t\tif (!strcmp(path, norm_pathspec)) {\n+\t\t\t\tpathspec_matches = 1;\n+\t\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t}\n+    }\n+\n+    /* If explicitly matched and forced, allow adding */\n+    if (pathspec_matches) {\n+\t\tif (ignored_too && ignored_too > 0) {\n+\t\t\ttrace_printf(\"Add submodule due to --force: %s\\n\", path);\n+\t\t\treturn 0;\n+\t\t} else {\n+\t\t\tadvise_if_enabled(ADVICE_ADD_IGNORED_FILE,\n+\t\t\t\t_(\"Skipping submodule due to ignore=all: %s\\n\"\n+\t\t\t\t\t\"Use --force if you really want to add the submodule.\"), path);\n+\t\t\treturn 1;\n+\t\t}\n+    }\n+\n+    /* No explicit pathspec match -> skip silently */\n+    trace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n+    return 1;\n+}\n+\n static void update_callback(struct diff_queue_struct *q,\n-\t\t\t    struct diff_options *opt UNUSED, void *cbdata)\n+\t\t\t\t\t\t\tstruct diff_options *opt UNUSED, void *cbdata)\n {\n \tint i;\n \tstruct update_callback_data *data = cbdata;\n@@ -3921,14 +3984,19 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tconst char *path = p->one->path;\n \n \t\tif (!data->include_sparse &&\n-\t\t    !path_in_sparse_checkout(path, data->index))\n+\t\t\t!path_in_sparse_checkout(path, data->index))\n \t\t\tcontinue;\n \n \t\tswitch (fix_unmerged_status(p, data)) {\n \t\tdefault:\n \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n \t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\t\tif (skip_submodule(path, data->repo,\n+\t\t\t\t\t\t\t\tdata->pathspec,\n+\t\t\t\t\t\t\t\tdata->ignored_too))\n+\t\t\t\tcontinue;\n+\n \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n \t\t\t\t\tdie(_(\"updating files failed\"));\n-- \ngitgitgadget\n\n"},{"id":"533802","messageId":"d7b97e12d37f614ad7979e3147df158109c9d57e.1768376879.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","subject":"[PATCH v3 3/5] tests: t2206-add-submodule-ignored: ignore=all and add --force tests","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-14T07:47:57Z","receivedAt":"2026-01-14T07:48:09Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe tests verify that the submodule behavior is intact and updating the\nconfig with ignore=all also behaves as intended with configuration in\n.gitmodules and configuration given on the command line.\n\nThe usage of --force is showcased and tested in the test suite.\n\nThe test file is added to meson.build for execution.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/meson.build                    |   1 +\n t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n 2 files changed, 135 insertions(+)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\ndiff --git a/t/meson.build b/t/meson.build\nindex a5531df415..a7d3e3e0a2 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -290,6 +290,7 @@ integration_tests = [\n   't2203-add-intent.sh',\n   't2204-add-ignored.sh',\n   't2205-add-worktree-config.sh',\n+  't2206-add-submodule-ignored.sh',\n   't2300-cd-to-toplevel.sh',\n   't2400-worktree-add.sh',\n   't2401-worktree-prune.sh',\ndiff --git a/t/t2206-add-submodule-ignored.sh b/t/t2206-add-submodule-ignored.sh\nnew file mode 100755\nindex 0000000000..e581e87ab2\n--- /dev/null\n+++ b/t/t2206-add-submodule-ignored.sh\n@@ -0,0 +1,134 @@\n+#!/bin/sh\n+# shellcheck disable=SC2016\n+\n+# shellcheck disable=SC2034\n+test_description='git add respects submodule ignore=all and explicit pathspec'\n+\n+# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n+# dealing with submodules that have the ignore=all setting in\n+# .gitmodules. It ensures that changes in such submodules are\n+# ignored by default, but can be staged with \"git add --force\".\n+\n+# shellcheck disable=SC1091\n+. ./test-lib.sh\n+\n+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n+base_path=$(pwd -P)\n+\n+#1\n+test_expect_success 'setup: create origin repos'  '\n+\tcd \"${base_path}\" &&\n+\tgit config --global protocol.file.allow always &&\n+\tgit init sub &&\n+\t\tpwd &&\n+\t\tcd sub &&\n+\t\ttest_commit sub_file1 &&\n+\t\tgit tag v1.0 &&\n+\t\ttest_commit sub_file2 &&\n+\t\tgit tag v2.0 &&\n+\t\ttest_commit sub_file3 &&\n+\t\tgit tag v3.0 &&\n+\tcd \"${base_path}\" &&\n+\tgit init main &&\n+\t\tcd main &&\n+\t\ttest_commit first &&\n+\tcd \"${base_path}\"\n+'\n+#2\n+# add submodule with default config (ignore=none) and\n+# check log that is contains a path entry for the submodule 'sub'\n+# change the commit in the submodule and check that 'git status' shows it as modified\n+test_expect_success 'main: add submodule with default config'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit submodule add ../sub &&\n+\tgit commit -m \"add submodule\" &&\n+\tgit log --oneline --name-only | grep \"^sub$\" &&\n+\tgit -C sub reset --hard v2.0 &&\n+\tgit status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+#3\n+# change the submodule config to ignore=all and check that status and log do not show changes\n+test_expect_success 'main: submodule config ignore=all'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit config -f .gitmodules submodule.sub.ignore all &&\n+\tGIT_TRACE=1 git add . &&\n+\tgit commit -m \"update submodule config sub.ignore all\" &&\n+\t! git status --porcelain | grep \"^.*$\" &&\n+\t! git log --oneline --name-only | grep \"^sub$\" &&\n+\techo\n+'\n+#4\n+# change the commit in the submodule and check that 'git status' does not show it as modified\n+# but 'git status --ignore-submodules=none' does show it as modified\n+test_expect_success 'sub: change to different sha1 and check status in main'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit -C sub reset --hard v1.0 &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit status --ignore-submodules=none --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#5\n+# check that normal 'git add' does not stage the change in the submodule\n+test_expect_success 'main: check normal add and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add . &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#6\n+# check that 'git add --force .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check --force add . and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add --force . &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#7\n+# check that 'git add .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check _add sub_ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add sub 2>&1 | grep \"Skipping submodule due to ignore=all: sub\" &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#8\n+# check that 'git add --force sub' does stage the change in the submodule\n+# check that 'git add --force ./sub/' does stage the change in the submodule\n+# and that 'git status --porcelain' does show it as modified\n+# commit it..\n+# check that 'git log --ignore-submodules=none' shows the submodule change\n+# in the log\n+test_expect_success 'main: check force add sub and ./sub/ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\techo \"Adding with --force should work: git add --force sub\" &&\n+\tGIT_TRACE=1 git add --force sub &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit restore --staged sub &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo \"Adding with --force should work: git add --force ./sub/\" &&\n+\tGIT_TRACE=1 git add --force ./sub/ &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit commit -m \"update submodule pointer\" &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit log --ignore-submodules=none --name-only --oneline | grep \"^sub$\" &&\n+\techo\n+'\n+\n+test_done\n+exit 0\n-- \ngitgitgadget\n\n"},{"id":"533804","messageId":"6e44ab6804b6f50d19702b7a10e05c5d028f0da1.1768376879.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","subject":"[PATCH v3 4/5] tests: fix existing tests when add an ignore=all submodule","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-14T07:47:58Z","receivedAt":"2026-01-14T07:48:10Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThere are tests that rely on \"git add <submodule>\" to update the in the\nreference in the parent repository which have been updated to use the\n--force option.\n\nUpdated tests:\n- t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t7406-submodule-update.sh\n- t7508-status.sh\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/lib-submodule-update.sh | 6 +++---\n t/t7508-status.sh         | 2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 36f767cb74..f591de6120 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -95,14 +95,14 @@ create_lib_submodule_repo () {\n \t\t\tgit commit -m \"modified file2 and added file3\" &&\n \t\t\tgit push origin modifications\n \t\t) &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -m \"Modify sub1\" &&\n \n \t\tgit checkout -b add_nested_sub modify_sub1 &&\n \t\tgit -C sub1 checkout -b \"add_nested_sub\" &&\n \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n \t\tgit checkout -b modify_sub1_recursively &&\n \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n@@ -112,7 +112,7 @@ create_lib_submodule_repo () {\n \t\tgit -C sub1/sub2 commit -m \"make a change in nested sub\" &&\n \t\tgit -C sub1 add sub2 &&\n \t\tgit -C sub1 commit -m \"update nested sub\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n \t\tgit -C sub1 push origin modify_sub1_recursively &&\n \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex abad229e9d..a5e21bf8bf 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1576,7 +1576,7 @@ test_expect_success 'git commit will commit a staged but ignored submodule' '\n \n test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n \tgit reset HEAD^ &&\n-\tgit add sm &&\n+\tgit add --force sm &&\n \tcat >expect << EOF &&\n On branch main\n Your branch and '\\''upstream'\\'' have diverged,\n-- \ngitgitgadget\n\n"},{"id":"533805","messageId":"37fe7956e089394bb1d75f4c8af4a3347b204803.1768376879.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","subject":"[PATCH v3 5/5] Documentation: update add --force option + ignore=all config","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-01-14T07:47:59Z","receivedAt":"2026-01-14T07:48:13Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\n- git-add.adoc: Update the --force documentation for submodule behaviour\n  to be added even the given configuration ignore=all.\n- gitmodules.adoc and config/submodule.adoc: The submodule config\n  ignore=all now need --force in order to update the index.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n Documentation/config/submodule.adoc | 13 +++++++------\n Documentation/git-add.adoc          |  5 ++++-\n Documentation/gitmodules.adoc       |  5 ++++-\n 3 files changed, 15 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config/submodule.adoc b/Documentation/config/submodule.adoc\nindex 0672d99117..250a6133d8 100644\n--- a/Documentation/config/submodule.adoc\n+++ b/Documentation/config/submodule.adoc\n@@ -32,15 +32,16 @@ submodule.<name>.fetchRecurseSubmodules::\n \n submodule.<name>.ignore::\n \tDefines under what circumstances \"git status\" and the diff family show\n-\ta submodule as modified. When set to \"all\", it will never be considered\n-\tmodified (but it will nonetheless show up in the output of status and\n-\tcommit when it has been staged), \"dirty\" will ignore all changes\n-\tto the submodule's work tree and\n+\ta submodule as modified.\n+\tSet to \"all\" will never consider the submodule modified. It can\n+\tnevertheless be staged using the option --force and it will then show up\n+\tin the output of status.\n+\tSet to \"dirty\" will ignore all changes to the submodule's work tree and\n \ttakes only differences between the HEAD of the submodule and the commit\n \trecorded in the superproject into account. \"untracked\" will additionally\n \tlet submodules with modified tracked files in their work tree show up.\n-\tUsing \"none\" (the default when this option is not set) also shows\n-\tsubmodules that have untracked files in their work tree as changed.\n+\tSet to \"none\"(default) It is also shows submodules that have untracked\n+\tfiles in their work tree as changed.\n \tThis setting overrides any setting made in .gitmodules for this submodule,\n \tboth settings can be overridden on the command line by using the\n \t\"--ignore-submodules\" option. The 'git submodule' commands are not\ndiff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\nindex 6192daeb03..941135dc63 100644\n--- a/Documentation/git-add.adoc\n+++ b/Documentation/git-add.adoc\n@@ -75,7 +75,10 @@ in linkgit:gitglossary[7].\n \n `-f`::\n `--force`::\n-\tAllow adding otherwise ignored files.\n+\tAllow adding otherwise ignored files. The option is also used when\n+\t`submodule.<name>.ignore=all` is set, but you want to stage an\n+\tupdate of the submodule. The `path` to the submodule must be explicitly\n+\tspecified.\n \n `--sparse`::\n \tAllow updating index entries outside of the sparse-checkout cone.\ndiff --git a/Documentation/gitmodules.adoc b/Documentation/gitmodules.adoc\nindex d9bec8b187..3792da96aa 100644\n--- a/Documentation/gitmodules.adoc\n+++ b/Documentation/gitmodules.adoc\n@@ -70,7 +70,10 @@ submodule.<name>.ignore::\n --\n \tall;; The submodule will never be considered modified (but will\n \t    nonetheless show up in the output of status and commit when it has\n-\t    been staged).\n+\t    been staged). Add `(new commits)` can be overruled using the\n+\t    `git add --force <submodule.path>`.\n+\t\tThe setting affects `status`, `update-index`, `diff` and `log`(due\n+\t\tto underlaying `diff`).\n \n \tdirty;; All changes to the submodule's work tree will be ignored, only\n \t    committed differences between the `HEAD` of the submodule and its\n-- \ngitgitgadget\n"},{"id":"533856","messageId":"B94F0800-06B5-47BC-8C22-AAE1882E5B9C@gmail.com","threadId":"64349","inReplyTo":"37fe7956e089394bb1d75f4c8af4a3347b204803.1768376879.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 5/5] Documentation: update add --force option + ignore=all config","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-01-14T17:53:17Z","receivedAt":"2026-01-14T17:53:28Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"\n> Le 14 janv. 2026 à 02:48, Claus Schneider(Eficode) via GitGitGadget <gitgitgadget@gmail.com> a écrit :\n> \n> ﻿From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n> \n> - git-add.adoc: Update the --force documentation for submodule behaviour\n>  to be added even the given configuration ignore=all.\n> - gitmodules.adoc and config/submodule.adoc: The submodule config\n>  ignore=all now need --force in order to update the index.\n> \n> Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> ---\n> Documentation/config/submodule.adoc | 13 +++++++------\n> Documentation/git-add.adoc          |  5 ++++-\n> Documentation/gitmodules.adoc       |  5 ++++-\n> 3 files changed, 15 insertions(+), 8 deletions(-)\n> \n> diff --git a/Documentation/config/submodule.adoc b/Documentation/config/submodule.adoc\n> index 0672d99117..250a6133d8 100644\n> --- a/Documentation/config/submodule.adoc\n> +++ b/Documentation/config/submodule.adoc\n> @@ -32,15 +32,16 @@ submodule.<name>.fetchRecurseSubmodules::\n> \n> submodule.<name>.ignore::\n>    Defines under what circumstances \"git status\" and the diff family show\n> -    a submodule as modified. When set to \"all\", it will never be considered\n> -    modified (but it will nonetheless show up in the output of status and\n> -    commit when it has been staged), \"dirty\" will ignore all changes\n> -    to the submodule's work tree and\n> +    a submodule as modified.\n> +    Set to \"all\" will never consider the\n\nThroughout this patch, missing “When set to…” for idiomatic English. \n\n> submodule modified. It can\n> +    nevertheless be staged using the option --force and it will then show up\n> +    in the output of status.\n> +    Set to \"dirty\" will ignore all changes to the submodule's work tree and\n>    takes only differences between the HEAD of the submodule and the commit\n>    recorded in the superproject into account. \"untracked\" will additionally\n>    let submodules with modified tracked files in their work tree show up.\n> -    Using \"none\" (the default when this option is not set) also shows\n> -    submodules that have untracked files in their work tree as changed.\n> +    Set to \"none\"(default) It is also shows submodules that have untracked\n> +    files in their work tree as changed.\n>    This setting overrides any setting made in .gitmodules for this submodule,\n>    both settings can be overridden on the command line by using the\n>    \"--ignore-submodules\" option. The 'git submodule' commands are not\n> diff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\n> index 6192daeb03..941135dc63 100644\n> --- a/Documentation/git-add.adoc\n> +++ b/Documentation/git-add.adoc\n> @@ -75,7 +75,10 @@ in linkgit:gitglossary[7].\n> \n> `-f`::\n> `--force`::\n> -    Allow adding otherwise ignored files.\n> +    Allow adding otherwise ignored files. The option is also used when\n> +    `submodule.<name>.ignore=all` is set, but you want to stage an\n> +    update of the submodule. The `path` to the submodule must be explicitly\n> +    specified.\n> \n> `--sparse`::\n>    Allow updating index entries outside of the sparse-checkout cone.\n> diff --git a/Documentation/gitmodules.adoc b/Documentation/gitmodules.adoc\n> index d9bec8b187..3792da96aa 100644\n> --- a/Documentation/gitmodules.adoc\n> +++ b/Documentation/gitmodules.adoc\n> @@ -70,7 +70,10 @@ submodule.<name>.ignore::\n> --\n>    all;; The submodule will never be considered modified (but will\n>        nonetheless show up in the output of status and commit when it has\n> -        been staged).\n> +        been staged). Add `(new commits)` can be overruled using the\n> +        `git add --force <submodule.path>`.\n> +        The setting affects `status`, `update-index`, `diff` and `log`(due\n> +        to underlaying `diff`).\n> \n>    dirty;; All changes to the submodule's work tree will be ignored, only\n>        committed differences between the `HEAD` of the submodule and its\n> --\n> gitgitgadget\n> \n"},{"id":"533964","messageId":"f021269b-c89c-41c8-aa08-2ec2443ac7e8@app.fastmail.com","threadId":"64349","inReplyTo":"de72bf0a9135224ed4c4a05ae00deadc28225ac0.1768376879.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 2/5] read-cache: submodule add need --force given ignore=all configuration","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-01-15T15:42:55Z","receivedAt":"2026-01-15T15:43:18Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Jan 14, 2026, at 08:47, Claus Schneider(Eficode) via GitGitGadget wrote:\n> From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n>\n> Submodules configured with ignore=all are now skipped during add operations\n> unless overridden by --force and the submodule path is explicitly specified.\n>\n> A message is printed (like ignored files) guiding the user to use the\n> --force flag if the user has explicitely want to update the submodule\n> reference.\n>\n> The reason for the change is support submodule branch tracking or\n> similar and git status states nothing and git add should not add either\n> as a default behaviour. The workflow is more logic and similar to regular\n> ignored files even the submodule is already tracked.\n>\n> The change opens up a lot of possibilities for submodules to be used\n> more freely and simular to the repo tool. A submodule can be added for many\n\ns/simular/similar/ ? Although the sentence doesn’t quite make sense to\nme. Well I’m unfamiliar with the domain anyway. ;)\n\n> more reason and loosely coupled dependencies to the super repo which often\n\ns/more reason/more reasons/ ?\n\n> gives the friction of handle the explicit commits and updates without\n\ns/handle/handling/\n\n> the need for tracking the submodule sha1 by sha1.\n>\n> Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> ---\n>[snip]\n"},{"id":"534048","messageId":"CA+GP4bqY02wcESuz1vPMcknigx_fUXFfi_xQ1EG_muGw6EszRg@mail.gmail.com","threadId":"64349","inReplyTo":"B94F0800-06B5-47BC-8C22-AAE1882E5B9C@gmail.com","subject":"Re: [PATCH v3 5/5] Documentation: update add --force option + ignore=all config","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2026-01-16T15:35:10Z","receivedAt":"2026-01-16T15:35:22Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Thanks for feedback. Noted and will be fixed as this:\n\n...\nWhen set to \"all\" will never consider the submodule modified. It can\nnevertheless be staged using the option --force and it will then show up\nin the output of status.\nWhen set to \"dirty\" will ignore all changes to the submodule's work tree and\ntakes only differences between the HEAD of the submodule and the commit\nrecorded in the superproject into account. \"untracked\" will additionally\nlet submodules with modified tracked files in their work tree show up.\nWhen set to \"none\"(default) It also show submodules as changed if they have\nuntracked files in their work tree.\n..\n// Claus\n\nOn Wed, Jan 14, 2026 at 6:53 PM Ben Knoble <ben.knoble@gmail.com> wrote:\n>\n>\n> > Le 14 janv. 2026 à 02:48, Claus Schneider(Eficode) via GitGitGadget <gitgitgadget@gmail.com> a écrit :\n> >\n> > ﻿From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n> >\n> > - git-add.adoc: Update the --force documentation for submodule behaviour\n> >  to be added even the given configuration ignore=all.\n> > - gitmodules.adoc and config/submodule.adoc: The submodule config\n> >  ignore=all now need --force in order to update the index.\n> >\n> > Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > ---\n> > Documentation/config/submodule.adoc | 13 +++++++------\n> > Documentation/git-add.adoc          |  5 ++++-\n> > Documentation/gitmodules.adoc       |  5 ++++-\n> > 3 files changed, 15 insertions(+), 8 deletions(-)\n> >\n> > diff --git a/Documentation/config/submodule.adoc b/Documentation/config/submodule.adoc\n> > index 0672d99117..250a6133d8 100644\n> > --- a/Documentation/config/submodule.adoc\n> > +++ b/Documentation/config/submodule.adoc\n> > @@ -32,15 +32,16 @@ submodule.<name>.fetchRecurseSubmodules::\n> >\n> > submodule.<name>.ignore::\n> >    Defines under what circumstances \"git status\" and the diff family show\n> > -    a submodule as modified. When set to \"all\", it will never be considered\n> > -    modified (but it will nonetheless show up in the output of status and\n> > -    commit when it has been staged), \"dirty\" will ignore all changes\n> > -    to the submodule's work tree and\n> > +    a submodule as modified.\n> > +    Set to \"all\" will never consider the\n>\n> Throughout this patch, missing “When set to…” for idiomatic English.\n>\n> > submodule modified. It can\n> > +    nevertheless be staged using the option --force and it will then show up\n> > +    in the output of status.\n> > +    Set to \"dirty\" will ignore all changes to the submodule's work tree and\n> >    takes only differences between the HEAD of the submodule and the commit\n> >    recorded in the superproject into account. \"untracked\" will additionally\n> >    let submodules with modified tracked files in their work tree show up.\n> > -    Using \"none\" (the default when this option is not set) also shows\n> > -    submodules that have untracked files in their work tree as changed.\n> > +    Set to \"none\"(default) It is also shows submodules that have untracked\n> > +    files in their work tree as changed.\n> >    This setting overrides any setting made in .gitmodules for this submodule,\n> >    both settings can be overridden on the command line by using the\n> >    \"--ignore-submodules\" option. The 'git submodule' commands are not\n> > diff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\n> > index 6192daeb03..941135dc63 100644\n> > --- a/Documentation/git-add.adoc\n> > +++ b/Documentation/git-add.adoc\n> > @@ -75,7 +75,10 @@ in linkgit:gitglossary[7].\n> >\n> > `-f`::\n> > `--force`::\n> > -    Allow adding otherwise ignored files.\n> > +    Allow adding otherwise ignored files. The option is also used when\n> > +    `submodule.<name>.ignore=all` is set, but you want to stage an\n> > +    update of the submodule. The `path` to the submodule must be explicitly\n> > +    specified.\n> >\n> > `--sparse`::\n> >    Allow updating index entries outside of the sparse-checkout cone.\n> > diff --git a/Documentation/gitmodules.adoc b/Documentation/gitmodules.adoc\n> > index d9bec8b187..3792da96aa 100644\n> > --- a/Documentation/gitmodules.adoc\n> > +++ b/Documentation/gitmodules.adoc\n> > @@ -70,7 +70,10 @@ submodule.<name>.ignore::\n> > --\n> >    all;; The submodule will never be considered modified (but will\n> >        nonetheless show up in the output of status and commit when it has\n> > -        been staged).\n> > +        been staged). Add `(new commits)` can be overruled using the\n> > +        `git add --force <submodule.path>`.\n> > +        The setting affects `status`, `update-index`, `diff` and `log`(due\n> > +        to underlaying `diff`).\n> >\n> >    dirty;; All changes to the submodule's work tree will be ignored, only\n> >        committed differences between the `HEAD` of the submodule and its\n> > --\n> > gitgitgadget\n> >\n"},{"id":"534050","messageId":"CA+GP4bpwMui5RT9ixo8iWyZ6XZDw3GnYhvgiqVmRq8dW7yo5RQ@mail.gmail.com","threadId":"64349","inReplyTo":"f021269b-c89c-41c8-aa08-2ec2443ac7e8@app.fastmail.com","subject":"Re: [PATCH v3 2/5] read-cache: submodule add need --force given ignore=all configuration","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2026-01-16T16:07:30Z","receivedAt":"2026-01-16T16:07:45Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Thanks for feedback. Well noted and it will be reworded like this:\n\n....\nA message is printed (like ignored files) guiding the user to use the\n--force flag if the user explicitly wants to update the submodule reference.\n\nThe reason for the change is to support branch tracking in submodules\n with configuration `submdule.<name>.branch` or similar workflows where the\nuser is not interested in tracking each update of the sha1 in the submdule.\nYou can additionally set `submodule.<name>.ignore=all` and the\n`git status`will state nothing and, with this patch, the `git add`\ndoes not either - as\nthe default behaviour. This patch changes the workflow to a more logical\nbehaviour and similar to workflow for ignored files.\n\nThe patch gives more scenarios for submodules to be used effectively with less\nfriction similar to the \"repo\" tool. A submodule can be added for many\ndifferent reasons than a hard dependency. It can be added as loosely coupled\ndependencies whereas the user wants the latest based on the configuration\n`submoule.<name>.branch`, but are not interested to track each commit in the\n`super-repo`. Currently it gives friction of handling conflicts between\nbranches even the sha1's are fast-forward and the user just wants the latest\nin any way. A developer can still add a sha1 explicitly to track updates.\n...\n\n// Claus\n\nOn Thu, Jan 15, 2026 at 4:43 PM Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> On Wed, Jan 14, 2026, at 08:47, Claus Schneider(Eficode) via GitGitGadget wrote:\n> > From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n> >\n> > Submodules configured with ignore=all are now skipped during add operations\n> > unless overridden by --force and the submodule path is explicitly specified.\n> >\n> > A message is printed (like ignored files) guiding the user to use the\n> > --force flag if the user has explicitely want to update the submodule\n> > reference.\n> >\n> > The reason for the change is support submodule branch tracking or\n> > similar and git status states nothing and git add should not add either\n> > as a default behaviour. The workflow is more logic and similar to regular\n> > ignored files even the submodule is already tracked.\n> >\n> > The change opens up a lot of possibilities for submodules to be used\n> > more freely and simular to the repo tool. A submodule can be added for many\n>\n> s/simular/similar/ ? Although the sentence doesn’t quite make sense to\n> me. Well I’m unfamiliar with the domain anyway. ;)\n>\n> > more reason and loosely coupled dependencies to the super repo which often\n>\n> s/more reason/more reasons/ ?\n>\n> > gives the friction of handle the explicit commits and updates without\n>\n> s/handle/handling/\n>\n> > the need for tracking the submodule sha1 by sha1.\n> >\n> > Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > ---\n> >[snip]\n"},{"id":"535215","messageId":"CA+GP4brx2CB5giQ+7Duh2yS4qXYEuWmBVrYG9RpZdtE7FOoWKA@mail.gmail.com","threadId":"64349","inReplyTo":"CA+GP4bob2A+GsVUo5vy+Mw0qJHDD5g+pyo2Ka1726ouUuS_=Wg@mail.gmail.com","subject":"Re: [PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2026-02-05T08:51:45Z","receivedAt":"2026-02-05T08:52:20Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Hi\n\nI have implemented the --ignore option. I believe it is done. Please\nreview it again for integration to 'next'.\n\nBest regards\nClaus Schneider\n\nOn Fri, Nov 14, 2025 at 2:53 PM Claus Schneider\n<claus.schneider@eficode.com> wrote:\n>\n> Thanks Junio - well received and noted. I have updated the PR\n> description accordingly, but I have not changed the \"--force\" in the\n> description even though I have implemented\n> ''--include-ignored-submodules' as Philip had the input not to use\n> \"--force\". He suggested using a new option. Philips comment:\n>\n> > I'm not convinced that the approach of using \"--force\" is a good idea as\n> > it conflates ignoring changes to tracked paths (which is what\n> > submodule.<name>.ignore\" does) with ignoring untracked paths (which is\n> > what \".gitignore\" does). If we're happy to break existing uses that rely\n> > on the current behavior then having a new option to override\n> > submodule.<name>.ignore strikes me as a better way forward. I don't have\n> > much experience of using submodules so I can't comment on whether\n> > changing the behavior is a good idea or not.\n>\n> I think it will be more simple to use the '--force' option though and\n> keep the amount of options lower and less to remember. Given your\n> comments about more usages of bytes for option also becomes obsolete\n> if we stick to \"--force\". I am happy to do so.\n>\n> I am investigating your other comments on the patches in the meantime.\n>\n> On Thu, Nov 13, 2025 at 8:58 PM Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> > \"Claus Schneider via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> >\n> > > The feature of configuring a submodule to \"ignore=all\" is nicely respected\n> > > in commands \"status\" and \"diff\".\n> >\n> > \"nicely respected\" is not very informative for those who do not know\n> > what the setting does.  Saying something like\n> >\n> >     \"git status\" and \"git diff\" will not report modified submodules\n> >     with submodule.<name>.ignore set to \"all\".\n> >\n> > would not waste significantly more bytes than what you wrote, and is\n> > more helpful.\n> >\n> > > However the \"add\" command does not respect\n> > > the configuration the same way.\n> >\n> > Again, \"does not respect\" and then what?  Running \"git add\" on a\n> > submodule with submodule.<name>.ignore set to \"all\" does what?\n> > Complains that it has changes but because .ignore is set it won't\n> > add?  Adds it silently?  Something else?\n> >\n> > > The behavior is problematic for the logic\n> > > between status/diff and add.\n> >\n> > After this sentence, \"because ...\" is missing.  Please help readers\n> > understand the issue you perceive as problematic more easily.\n> >\n> > I am guessing that you are assuming that an \"add\", after \"diff\" or\n> > \"status\" said there is no change, is expected to be a no-op, but I\n> > cannot be sure if that is what you are referring to here with the\n> > reason left unsaid like the above.\n> >\n> > > Secondly it makes it problematic to track\n> > > branches in the submodule configuration as developers unintentionally keeps\n> > > add submodule updates and get conflicts for no intentional reason. Both adds\n> > > unnecessary friction to the usage of submodules.\n> > >\n> > > The patches implement the same logical behavior for ignore=all submodules as\n> > > regular ignored files. The status now does not show any diff - nor will the\n> > > add command update the reference submodule reference. If you add the\n> > > submodule path which is ignore=all then you are presented with a message\n> > > that you need to use the --force option.\n> >\n> > I vaguely recall that an earlier discussion between you and Phillip\n> > were concluding against \"--force\"?  I personally feel it is in line\n> > with \"git add foo.o\" (when '*.o' is in .gitignore) gets rejected and\n> > \"git add -f foo.o\" is a way to override it, but in the list of\n> > patches below, I see --include-ignored-submodules (no, our command\n> > line option names do not use underscore for inter-word-gaps), so I\n> > suspect the description in the cover letter around here is stale?\n> >\n> >\n> > > The branch=, ignore=all (and\n> > > update=none) now works great with update --remote,\n> >\n> > Again, \"great\" is not very informative, and as bad as \"nicely\n> > respected\".  Avoid using these adjectives loaded with unnecessary\n> > value judgements, and instead trust your readers.  They are\n> > intelligent to judge if the updated behaviour is great or not for\n> > themselves.  Try to use the same bytes on helping readers understand\n> > what actually happens.\n> >\n> > > but developers does not\n> >\n> > \"do not\".\n> >\n> > > have to consider changes in the updates of the submodule sha1. The\n> > > implementation removes a friction of working with submodules and can be used\n> > > like the repo tool with branches configured. The submodule status report\n> > > could be used for build/release documentation for reproduction of a setup.\n> > >\n> > > A few tests used the adding of submodules without --force, hence they have\n> > > been updated to use the --force option.\n> > >\n> > > Claus Schneider(Eficode) (5):\n> > >   read-cache: update add_files_to_cache take param\n> > >     include_ignored_submodules\n> > >   read-cache: add/read-cache respect submodule ignore=all\n> > >   tests: add new t2206-add-submodule-ignored.sh to test ignore=all\n> > >     scenario\n> > >   tests: fix existing tests when add an ignore=all submodule\n> > >   Documentation: add --include_ignored_submodules + ignore=all config\n> > >\n> > >  .devcontainer/Dockerfile            |  70 +++++++++++++++\n> > >  .devcontainer/Dockerfile.standalone |  76 ++++++++++++++++\n> > >  .devcontainer/devcontainer.json     |  25 ++++++\n> > >  Documentation/config/submodule.adoc |  13 +--\n> > >  Documentation/git-add.adoc          |   5 ++\n> > >  Documentation/gitmodules.adoc       |   5 +-\n> > >  builtin/add.c                       |   4 +-\n> > >  builtin/checkout.c                  |   2 +-\n> > >  builtin/commit.c                    |   2 +-\n> > >  read-cache-ll.h                     |   2 +-\n> > >  read-cache.c                        |  54 ++++++++++-\n> > >  t/lib-submodule-update.sh           |   6 +-\n> > >  t/meson.build                       |   1 +\n> > >  t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++\n> > >  t/t7508-status.sh                   |   2 +-\n> > >  15 files changed, 384 insertions(+), 17 deletions(-)\n> > >  create mode 100644 .devcontainer/Dockerfile\n> > >  create mode 100644 .devcontainer/Dockerfile.standalone\n> > >  create mode 100644 .devcontainer/devcontainer.json\n> > >  create mode 100755 t/t2206-add-submodule-ignored.sh\n> > >\n> > >\n> > > base-commit: 81f86aacc4eb74cdb9c2c8082d36d2070c666045\n> > > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v2\n> > > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v2\n> > > Pull-Request: https://github.com/gitgitgadget/git/pull/1987\n> > >\n> > > Range-diff vs v1:\n> > >\n> > >  1:  d98cca698d ! 1:  5796009122 read-cache: update add_files_to_cache to take param ignored_too(--force)\n> > >      @@ Metadata\n> > >       Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > >\n> > >        ## Commit message ##\n> > >      -    read-cache: update add_files_to_cache to take param ignored_too(--force)\n> > >      +    read-cache: update add_files_to_cache take param include_ignored_submodules\n> > >\n> > >      -    The ignored_too parameter is added to the function add_files_to_cache for\n> > >      -    usage of explicit updating the index for the updated submodule using the\n> > >      -    explicit patchspec to the submodule.\n> > >      +    The include_ignored_submodules parameter is added to the function\n> > >      +    add_files_to_cache for usage of explicit updating the index for the updated\n> > >      +    submodule using the explicit patchspec to the submodule.\n> > >\n> > >           Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > >\n> > >        ## builtin/add.c ##\n> > >      +@@ builtin/add.c: N_(\"The following paths are ignored by one of your .gitignore files:\\n\");\n> > >      + static int verbose, show_only, ignored_too, refresh_only;\n> > >      + static int ignore_add_errors, intent_to_add, ignore_missing;\n> > >      + static int warn_on_embedded_repo = 1;\n> > >      ++static int include_ignored_submodules;\n> > >      +\n> > >      + #define ADDREMOVE_DEFAULT 1\n> > >      + static int addremove = ADDREMOVE_DEFAULT;\n> > >      +@@ builtin/add.c: static struct option builtin_add_options[] = {\n> > >      +        OPT_BOOL( 0 , \"ignore-errors\", &ignore_add_errors, N_(\"just skip files which cannot be added because of errors\")),\n> > >      +        OPT_BOOL( 0 , \"ignore-missing\", &ignore_missing, N_(\"check if - even missing - files are ignored in dry run\")),\n> > >      +        OPT_BOOL(0, \"sparse\", &include_sparse, N_(\"allow updating entries outside of the sparse-checkout cone\")),\n> > >      ++    OPT_BOOL(0, \"include-ignored-submodules\", &include_ignored_submodules, N_(\"add submodules even if they has configuration ignore=all\")),\n> > >      +        OPT_STRING(0, \"chmod\", &chmod_arg, \"(+|-)x\",\n> > >      +                   N_(\"override the executable bit of the listed files\")),\n> > >      +        OPT_HIDDEN_BOOL(0, \"warn-embedded-repo\", &warn_on_embedded_repo,\n> > >       @@ builtin/add.c: int cmd_add(int argc,\n> > >               else\n> > >                       exit_status |= add_files_to_cache(repo, prefix,\n> > >                                                         &pathspec, ps_matched,\n> > >       -                                                 include_sparse, flags);\n> > >      -+                                                 include_sparse, flags, ignored_too);\n> > >      ++                                                 include_sparse, flags, include_ignored_submodules);\n> > >\n> > >               if (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n> > >                   report_path_error(ps_matched, &pathspec))\n> > >      @@ read-cache.c: void overlay_tree_on_index(struct index_state *istate,\n> > >               int include_sparse;\n> > >               int flags;\n> > >               int add_errors;\n> > >      -+       int ignored_too;\n> > >      ++       int include_ignored_submodules;\n> > >        };\n> > >\n> > >        static int fix_unmerged_status(struct diff_filepair *p,\n> > >       @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> > >      +                default:\n> > >      +                        die(_(\"unexpected diff status %c\"), p->status);\n> > >      +                case DIFF_STATUS_MODIFIED:\n> > >      +-               case DIFF_STATUS_TYPE_CHANGED:\n> > >      ++               case DIFF_STATUS_TYPE_CHANGED: {\n> > >      ++                       struct stat st;\n> > >      ++                       if (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n> > >      ++                               const struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n> > >      ++                               if (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n> > >      ++                                       int pathspec_matches = 0;\n> > >      ++                                       char *norm_pathspec = NULL;\n> > >      ++                                       int ps_i;\n> > >      ++                                       trace_printf(\"ignore=all %s\\n\", path);\n> > >      ++                                       trace_printf(\"pathspec %s\\n\",\n> > >      ++                                                       (data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n> > >      ++                                       /* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n> > >      ++                                       if (data->pathspec) {\n> > >      ++                                               for (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n> > >      ++                                                       const char *m = data->pathspec->items[ps_i].match;\n> > >      ++                                                       if (!m)\n> > >      ++                                                               continue;\n> > >      ++                                                       norm_pathspec = xstrdup(m);\n> > >      ++                                                       strip_dir_trailing_slashes(norm_pathspec);\n> > >      ++                                                       if (!strcmp(path, norm_pathspec)) {\n> > >      ++                                                               pathspec_matches = 1;\n> > >      ++                                                               FREE_AND_NULL(norm_pathspec);\n> > >      ++                                                               break;\n> > >      ++                                                       }\n> > >      ++                                                       FREE_AND_NULL(norm_pathspec);\n> > >      ++                                               }\n> > >      ++                                       }\n> > >      ++                                       if (pathspec_matches) {\n> > >      ++                                               if (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n> > >      ++                                                       trace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n> > >      ++                                               } else {\n> > >      ++                                                       printf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n> > >      ++                                                       printf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n> > >      ++                                                       continue;\n> > >      ++                                               }\n> > >      ++                                       } else {\n> > >      ++                                               /* No explicit pathspec match -> skip silently (or with trace). */\n> > >      ++                                               trace_printf(\"pathspec does not match %s\\n\", path);\n> > >      ++                                               continue;\n> > >      ++                                       }\n> > >      ++                               }\n> > >      ++                       }\n> > >      +                        if (add_file_to_index(data->index, path, data->flags)) {\n> > >      +                                if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n> > >      +                                        die(_(\"updating files failed\"));\n> > >      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> > >\n> > >        int add_files_to_cache(struct repository *repo, const char *prefix,\n> > >                              const struct pathspec *pathspec, char *ps_matched,\n> > >       -                      int include_sparse, int flags)\n> > >      -+                      int include_sparse, int flags, int ignored_too )\n> > >      ++                      int include_sparse, int flags, int include_ignored_submodules )\n> > >        {\n> > >               struct update_callback_data data;\n> > >               struct rev_info rev;\n> > >      @@ read-cache.c: int add_files_to_cache(struct repository *repo, const char *prefix\n> > >               data.include_sparse = include_sparse;\n> > >               data.flags = flags;\n> > >       +       data.repo = repo;\n> > >      -+       data.ignored_too = ignored_too;\n> > >      ++       data.include_ignored_submodules = include_ignored_submodules;\n> > >       +       data.pathspec = (struct pathspec *)pathspec;\n> > >\n> > >               repo_init_revisions(repo, &rev, prefix);\n> > >  2:  d1b02617e6 ! 2:  9ec79b9a11 read-cache: let read-cache respect submodule ignore=all and --force\n> > >      @@ Metadata\n> > >       Author: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > >\n> > >        ## Commit message ##\n> > >      -    read-cache: let read-cache respect submodule ignore=all and --force\n> > >      +    read-cache: add/read-cache respect submodule ignore=all\n> > >\n> > >      -    Given the submdule configuration is ignore=all then only update the\n> > >      -    submdule if the --force option is given and the submodule is explicit\n> > >      -    given in the pathspec.\n> > >      +    Submodules configured with ignore=all are now skipped during add operations\n> > >      +    unless overridden by --include-ignored-submodules and the submodule path is\n> > >      +    explicitly specified.\n> > >\n> > >           A message is printed (like ignored files) guiding the user to use the\n> > >      -    --force flag if the user has explicitely want to update the submodule\n> > >      -    reference.\n> > >      +    --include-ignored-submodules flag if the user has explicitely want to update\n> > >      +    the submodule reference.\n> > >\n> > >           The reason for the change is support submodule branch tracking or\n> > >           similar and git status state nothing and git add should not add either.\n> > >      @@ Commit message\n> > >           the submodule is already tracked.\n> > >\n> > >           The change opens up a lot of possibilities for submodules to be used\n> > >      -    more freely and a like the repo tool. A submodule can be added for many\n> > >      +    more freely and simular to the repo tool. A submodule can be added for many\n> > >           more reason and loosely coupled dependencies to the super repo which often\n> > >           gives the friction of handle the explicit commits and updates without\n> > >           the need for tracking the submodule sha1 by sha1.\n> > >      @@ read-cache.c\n> > >        /* Mask for the name length in ce_flags in the on-disk index */\n> > >\n> > >       @@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> > >      -                default:\n> > >      -                        die(_(\"unexpected diff status %c\"), p->status);\n> > >      -                case DIFF_STATUS_MODIFIED:\n> > >      --               case DIFF_STATUS_TYPE_CHANGED:\n> > >      -+               case DIFF_STATUS_TYPE_CHANGED: {\n> > >      -+                       struct stat st;\n> > >      -+                       if (!lstat(path, &st) && S_ISDIR(st.st_mode)) { // only consider submodule if it is a directory\n> > >      -+                               const struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path);\n> > >      -+                               if (sub && sub->name && sub->ignore && !strcmp(sub->ignore, \"all\")) {\n> > >      -+                                       int pathspec_matches = 0;\n> > >      -+                                       char *norm_pathspec = NULL;\n> > >      -+                                       int ps_i;\n> > >      -+                                       trace_printf(\"ignore=all %s\\n\", path);\n> > >      -+                                       trace_printf(\"pathspec %s\\n\",\n> > >      -+                                                       (data->pathspec && data->pathspec->nr) ? \"has pathspec\" : \"no pathspec\");\n> > >      -+                                       /* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */\n> > >      -+                                       if (data->pathspec) {\n> > >      -+                                               for (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) {\n> > >      -+                                                       const char *m = data->pathspec->items[ps_i].match;\n> > >      -+                                                       if (!m)\n> > >      -+                                                               continue;\n> > >      -+                                                       norm_pathspec = xstrdup(m);\n> > >      -+                                                       strip_dir_trailing_slashes(norm_pathspec);\n> > >      -+                                                       if (!strcmp(path, norm_pathspec)) {\n> > >      -+                                                               pathspec_matches = 1;\n> > >      -+                                                               FREE_AND_NULL(norm_pathspec);\n> > >      -+                                                               break;\n> > >      -+                                                       }\n> > >      -+                                                       FREE_AND_NULL(norm_pathspec);\n> > >      -+                                               }\n> > >      -+                                       }\n> > >      -+                                       if (pathspec_matches) {\n> > >      -+                                               if (data->ignored_too && data->ignored_too > 0) {\n> > >      -+                                                       trace_printf(\"Forcing add of submodule ignored=all due to --force: %s\\n\", path);\n> > >      -+                                               } else {\n> > >      -+                                                       printf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n> > >      -+                                                       printf(_(\"Use -f if you really want to add them.\") );\n> > >      -+                                                       continue;\n> > >      -+                                               }\n> > >      -+                                       } else {\n> > >      -+                                               /* No explicit pathspec match -> skip silently (or with trace). */\n> > >      -+                                               trace_printf(\"pathspec does not match %s\\n\", path);\n> > >      -+                                               continue;\n> > >      -+                                       }\n> > >      -+                               }\n> > >      -+                       }\n> > >      -                        if (add_file_to_index(data->index, path, data->flags)) {\n> > >      -                                if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n> > >      -                                        die(_(\"updating files failed\"));\n> > >      +                                        }\n> > >      +                                        if (pathspec_matches) {\n> > >      +                                                if (data->include_ignored_submodules && data->include_ignored_submodules > 0) {\n> > >      +-                                                       trace_printf(\"Add ignored=all submodule due to --include_ignored_submodules: %s\\n\", path);\n> > >      ++                                                       trace_printf(\"Add submodule due to --include_ignored_submodules: %s\\n\", path);\n> > >      +                                                } else {\n> > >      +                                                        printf(_(\"Skipping submodule due to ignore=all: %s\"), path);\n> > >      +                                                        printf(_(\"Use --include_ignored_submodules, if you really want to add them.\") );\n> > >      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> > >      +                                                }\n> > >      +                                        } else {\n> > >      +                                                /* No explicit pathspec match -> skip silently (or with trace). */\n> > >      +-                                               trace_printf(\"pathspec does not match %s\\n\", path);\n> > >      ++                                               trace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n> > >      +                                                continue;\n> > >      +                                        }\n> > >      +                                }\n> > >      +@@ read-cache.c: static void update_callback(struct diff_queue_struct *q,\n> > >                                       data->add_errors++;\n> > >                               }\n> > >                               break;\n> > >  3:  8f3d5f7ec1 ! 3:  399a153b95 tests: add new t2206-add-submodule-ignored.sh to test ignore=all scenario\n> > >      @@ Commit message\n> > >           config with ignore=all also behaves as intended with configuration in\n> > >           .gitmodules and configuration given on the command line.\n> > >\n> > >      -    Testfile is added to meson.build for execution.\n> > >      +    The usage of --include_ignored_submodules is showcased and tested in the\n> > >      +    test suite.\n> > >      +\n> > >      +    The test file is added to meson.build for execution.\n> > >\n> > >           Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > >\n> > >      @@ t/t2206-add-submodule-ignored.sh (new)\n> > >       +# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n> > >       +# dealing with submodules that have the ignore=all setting in\n> > >       +# .gitmodules. It ensures that changes in such submodules are\n> > >      -+# ignored by default, but can be staged with \"git add --force\".\n> > >      ++# ignored by default, but can be staged with \"git add --include-ignored-submodules\".\n> > >       +\n> > >       +# shellcheck disable=SC1091\n> > >       +. ./test-lib.sh\n> > >      @@ t/t2206-add-submodule-ignored.sh (new)\n> > >       +'\n> > >       +\n> > >       +#6\n> > >      -+# check that 'git add --force .' does not stage the change in the submodule\n> > >      ++# check that 'git add --include-ignored-submodules .' does not stage the change in the submodule\n> > >       +# and that 'git status' does not show it as modified\n> > >      -+test_expect_success 'main: check --force add . and status'  '\n> > >      ++test_expect_success 'main: check --include-ignored-submodules add . and status'  '\n> > >       +       cd \"${base_path}\" &&\n> > >       +       cd main &&\n> > >      -+       GIT_TRACE=1 git add --force . &&\n> > >      ++       GIT_TRACE=1 git add --include-ignored-submodules . &&\n> > >       +       ! git status --porcelain | grep \"^M  sub$\" &&\n> > >       +       echo\n> > >       +'\n> > >      @@ t/t2206-add-submodule-ignored.sh (new)\n> > >       +'\n> > >       +\n> > >       +#8\n> > >      -+# check that 'git add --force sub' does stage the change in the submodule\n> > >      -+# check that 'git add --force ./sub/' does stage the change in the submodule\n> > >      ++# check that 'git add --include-ignored-submodules sub' does stage the change in the submodule\n> > >      ++# check that 'git add --include-ignored-submodules ./sub/' does stage the change in the submodule\n> > >       +# and that 'git status --porcelain' does show it as modified\n> > >       +# commit it..\n> > >       +# check that 'git log --ignore-submodules=none' shows the submodule change\n> > >      @@ t/t2206-add-submodule-ignored.sh (new)\n> > >       +test_expect_success 'main: check force add sub and ./sub/ and status'  '\n> > >       +       cd \"${base_path}\" &&\n> > >       +       cd main &&\n> > >      -+       echo \"Adding with --force should work: git add --force sub\" &&\n> > >      -+       GIT_TRACE=1 git add --force sub &&\n> > >      ++       echo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules sub\" &&\n> > >      ++       GIT_TRACE=1 git add --include-ignored-submodules sub &&\n> > >       +       git status --porcelain | grep \"^M  sub$\" &&\n> > >       +       git restore --staged sub &&\n> > >       +       ! git status --porcelain | grep \"^M  sub$\" &&\n> > >      -+       echo \"Adding with --force should work: git add --force ./sub/\" &&\n> > >      -+       GIT_TRACE=1 git add --force ./sub/ &&\n> > >      ++       echo \"Adding with --include-ignored-submodules should work: git add --include-ignored-submodules ./sub/\" &&\n> > >      ++       GIT_TRACE=1 git add --include-ignored-submodules ./sub/ &&\n> > >       +       git status --porcelain | grep \"^M  sub$\" &&\n> > >       +       git commit -m \"update submodule pointer\" &&\n> > >       +       ! git status --porcelain | grep \"^ M sub$\" &&\n> > >  4:  58563a7b90 ! 4:  93c95954f1 tests: fix existing tests when add an ignore=all submodule\n> > >      @@ Metadata\n> > >        ## Commit message ##\n> > >           tests: fix existing tests when add an ignore=all submodule\n> > >\n> > >      -    There are tests that rely on \"git add <submodule>\" also adds it. A --force\n> > >      -    is needed with this enhancement hence they are added accordingly in these\n> > >      -    tests.\n> > >      +    There are tests that rely on \"git add <submodule>\" to add updates in the\n> > >      +    parent repository. A new option --include-ignored-submodules is introduced\n> > >      +    as it is now needed with this enhancement.\n> > >\n> > >           Updated tests:\n> > >           - t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n> > >      +    - t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n> > >           - t7406-submodule-update.sh\n> > >           - t7508-status.sh\n> > >\n> > >      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n> > >                               git push origin modifications\n> > >                       ) &&\n> > >       -               git add sub1 &&\n> > >      -+               git add --force sub1 &&\n> > >      ++               git add --include-ignored-submodules sub1 &&\n> > >                       git commit -m \"Modify sub1\" &&\n> > >\n> > >                       git checkout -b add_nested_sub modify_sub1 &&\n> > >      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n> > >                       git -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n> > >                       git -C sub1 commit -a -m \"add a nested submodule\" &&\n> > >       -               git add sub1 &&\n> > >      -+               git add --force sub1 &&\n> > >      ++               git add --include-ignored-submodules sub1 &&\n> > >                       git commit -a -m \"update submodule, that updates a nested submodule\" &&\n> > >                       git checkout -b modify_sub1_recursively &&\n> > >                       git -C sub1 checkout -b modify_sub1_recursively &&\n> > >      @@ t/lib-submodule-update.sh: create_lib_submodule_repo () {\n> > >                       git -C sub1 add sub2 &&\n> > >                       git -C sub1 commit -m \"update nested sub\" &&\n> > >       -               git add sub1 &&\n> > >      -+               git add --force sub1 &&\n> > >      ++               git add --include-ignored-submodules sub1 &&\n> > >                       git commit -m \"update sub1, that updates nested sub\" &&\n> > >                       git -C sub1 push origin modify_sub1_recursively &&\n> > >                       git -C sub1/sub2 push origin modify_sub1_recursively &&\n> > >      @@ t/t7508-status.sh: test_expect_success 'git commit will commit a staged but igno\n> > >        test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n> > >               git reset HEAD^ &&\n> > >       -       git add sm &&\n> > >      -+       git add --force sm &&\n> > >      ++       git add --include-ignored-submodules sm &&\n> > >               cat >expect << EOF &&\n> > >        On branch main\n> > >        Your branch and '\\''upstream'\\'' have diverged,\n> > >  5:  416695f439 < -:  ---------- Documentation: update add --force and submodule ignore=all config\n> > >  -:  ---------- > 5:  ee84190cd8 Documentation: add --include_ignored_submodules + ignore=all config\n"},{"id":"535287","messageId":"xmqqms1mkfr4.fsf@gitster.g","threadId":"64349","inReplyTo":"CA+GP4brx2CB5giQ+7Duh2yS4qXYEuWmBVrYG9RpZdtE7FOoWKA@mail.gmail.com","subject":"Re: [PATCH v2 0/5] git-add : Respect submodule ignore=all and only add changes with --force","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-05T22:05:51Z","receivedAt":"2026-02-05T22:05:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Claus Schneider <claus.schneider@eficode.com> writes:\n\n> Hi\n>\n> I have implemented the --ignore option. I believe it is done. Please\n> review it again for integration to 'next'.\n>\n> Best regards\n> Claus Schneider\n\nSorry, but I am confused to see this follow-up to [v2 0/5], after I\nsaw at least two messages from you that said something like\n\n    Thanks for feedback. Noted and will be fixed as this:\n\nin review thread for the [v3].  I admit that \"What's cooking\" report\noften has stale entries, but for this topic, I think its recent\neditions reflect the latest status of this thread correctly.\n\n* cs/add-skip-submodule-ignore-all (2026-01-13) 5 commits\n - Documentation: update add --force option + ignore=all config\n - tests: fix existing tests when add an ignore=all submodule\n - tests: t2206-add-submodule-ignored: ignore=all and add --force tests\n - read-cache: submodule add need --force given ignore=all configuration\n - read-cache: update add_files_to_cache take param ignored_too\n\n \"git add <submodule>\" has been taught to honor\n submodule.<name>.ignore that is set to \"all\" (and requires \"git add\n -f\" to override it).\n\n Expecting a reroll.\n cf. <CA+GP4bqY02wcESuz1vPMcknigx_fUXFfi_xQ1EG_muGw6EszRg@mail.gmail.com>\n cf. <CA+GP4bpwMui5RT9ixo8iWyZ6XZDw3GnYhvgiqVmRq8dW7yo5RQ@mail.gmail.com>\n source: <37fe7956e089394bb1d75f4c8af4a3347b204803.1768376879.git.gitgitgadget@gmail.com>\n\n"},{"id":"535334","messageId":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v3.git.1768376879.gitgitgadget@gmail.com","subject":"[PATCH v4 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used","fromName":"Claus Schneider via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-06T13:22:55Z","receivedAt":"2026-02-06T13:23:03Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"The ignore=all configuration for submodules is currently honored by status\nand diff, but not by add. This inconsistency causes friction when working\nwith submodules:\n\n * Developers unintentionally stage submodule updates, leading to conflicts\n   and unnecessary changes.\n * Tracking branches in submodule configs causes friction as updates to the\n   submodule SHA1 are added without intent.\n\nThis patch aligns git add with the behavior of status and diff:\n\n * Submodules marked ignore=all are skipped by default.\n * Attempting to add such a submodule explicitly now requires --force.\n\nA submodule can frictionless track a branch in the configuration or manually\nswitched to and use update --update --remote without unintentionally add the\nchanges to the super-project.\n\nTests that previously added submodules without --force have been updated\naccordingly. A new test is added to test the behavior of git add with and\nwithout --force.\n\nClaus Schneider(Eficode) (5):\n  read-cache: update add_files_to_cache take param ignored_too\n  read-cache: submodule add need --force given ignore=all configuration\n  tests: t2206-add-submodule-ignored: ignore=all and add --force tests\n  tests: fix existing tests when add an ignore=all submodule\n  Documentation: update add --force option + ignore=all config\n\n Documentation/config/submodule.adoc |  13 +--\n Documentation/git-add.adoc          |   5 +-\n Documentation/gitmodules.adoc       |   5 +-\n builtin/add.c                       |   2 +-\n builtin/checkout.c                  |   2 +-\n builtin/commit.c                    |   2 +-\n read-cache-ll.h                     |   2 +-\n read-cache.c                        |  80 ++++++++++++++++-\n t/lib-submodule-update.sh           |   6 +-\n t/meson.build                       |   1 +\n t/t2206-add-submodule-ignored.sh    | 134 ++++++++++++++++++++++++++++\n t/t7508-status.sh                   |   2 +-\n 12 files changed, 235 insertions(+), 19 deletions(-)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\n\nbase-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1987%2FPraqma%2Frespect-submodule-ignore-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1987/Praqma/respect-submodule-ignore-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/1987\n\nRange-diff vs v3:\n\n 1:  d2b66286c2 = 1:  69e0065b1b read-cache: update add_files_to_cache take param ignored_too\n 2:  de72bf0a91 ! 2:  504edcb0f5 read-cache: submodule add need --force given ignore=all configuration\n     @@ Commit message\n          unless overridden by --force and the submodule path is explicitly specified.\n      \n          A message is printed (like ignored files) guiding the user to use the\n     -    --force flag if the user has explicitely want to update the submodule\n     -    reference.\n     +    --force flag if the user explicitly wants to update the submodule reference.\n      \n     -    The reason for the change is support submodule branch tracking or\n     -    similar and git status states nothing and git add should not add either\n     -    as a default behaviour. The workflow is more logic and similar to regular\n     -    ignored files even the submodule is already tracked.\n     +    The reason for the change is to support branch tracking in submodules\n     +    with configuration `submdule.<name>.branch` or similar workflows where the\n     +    user is not interested in tracking each update of the sha1 in the submdule.\n     +    You can additionally set `submodule.<name>.ignore=all` and the `git status`\n     +    will state nothing and, with this patch, the `git add` does not either - as\n     +    the default behaviour. This patch changes the workflow to a more logical\n     +    behaviour and similar to workflow for ignored files.\n      \n     -    The change opens up a lot of possibilities for submodules to be used\n     -    more freely and simular to the repo tool. A submodule can be added for many\n     -    more reason and loosely coupled dependencies to the super repo which often\n     -    gives the friction of handle the explicit commits and updates without\n     -    the need for tracking the submodule sha1 by sha1.\n     +    The patch gives more scenarios for submodules to be used effectively with\n     +    less friction similar to the \"repo\" tool. A submodule can be added for many\n     +    different reasons than a hard dependency. It can be added as loosely\n     +    coupled dependencies whereas the user wants the latest based on the\n     +    configuration `submoule.<name>.branch`, but are not interested to track\n     +    each commit in the `super-repo`. Currently it gives friction of handling\n     +    conflicts between branches even the sha1's are fast-forward and the user\n     +    just wants the latest in any way. The user can still add a sha1 explicitly\n     +    to track updates.\n      \n          Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n      \n 3:  d7b97e12d3 = 3:  d5ea8eb6e0 tests: t2206-add-submodule-ignored: ignore=all and add --force tests\n 4:  6e44ab6804 = 4:  df5c85d9f2 tests: fix existing tests when add an ignore=all submodule\n 5:  37fe7956e0 ! 5:  8bfaa14d44 Documentation: update add --force option + ignore=all config\n     @@ Documentation/config/submodule.adoc: submodule.<name>.fetchRecurseSubmodules::\n      -\tcommit when it has been staged), \"dirty\" will ignore all changes\n      -\tto the submodule's work tree and\n      +\ta submodule as modified.\n     -+\tSet to \"all\" will never consider the submodule modified. It can\n     ++\tWhen set to \"all\" will never consider the submodule modified. It can\n      +\tnevertheless be staged using the option --force and it will then show up\n      +\tin the output of status.\n     -+\tSet to \"dirty\" will ignore all changes to the submodule's work tree and\n     ++\tWhen set to \"dirty\" will ignore all changes to the submodule's work tree and\n       \ttakes only differences between the HEAD of the submodule and the commit\n       \trecorded in the superproject into account. \"untracked\" will additionally\n       \tlet submodules with modified tracked files in their work tree show up.\n      -\tUsing \"none\" (the default when this option is not set) also shows\n      -\tsubmodules that have untracked files in their work tree as changed.\n     -+\tSet to \"none\"(default) It is also shows submodules that have untracked\n     -+\tfiles in their work tree as changed.\n     ++\tWhen set to \"none\"(default) It also show submodules as changed if they have\n     ++\tuntracked files in their work tree.\n       \tThis setting overrides any setting made in .gitmodules for this submodule,\n       \tboth settings can be overridden on the command line by using the\n       \t\"--ignore-submodules\" option. The 'git submodule' commands are not\n\n-- \ngitgitgadget\n"},{"id":"535335","messageId":"69e0065b1bfe469c25f023592a5a6600d49348dc.1770384180.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","subject":"[PATCH v4 1/5] read-cache: update add_files_to_cache take param ignored_too","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-06T13:22:56Z","receivedAt":"2026-02-06T13:23:05Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe ignored_too parameter is added to the function\nadd_files_to_cache for usage of explicit updating the index for the updated\nsubmodule using the explicit patchspec to the submodule.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n builtin/add.c      |  2 +-\n builtin/checkout.c |  2 +-\n builtin/commit.c   |  2 +-\n read-cache-ll.h    |  2 +-\n read-cache.c       | 10 ++++++++--\n 5 files changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 32709794b3..eef4959ee3 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -584,7 +584,7 @@ int cmd_add(int argc,\n \telse\n \t\texit_status |= add_files_to_cache(repo, prefix,\n \t\t\t\t\t\t  &pathspec, ps_matched,\n-\t\t\t\t\t\t  include_sparse, flags);\n+\t\t\t\t\t\t  include_sparse, flags, ignored_too);\n \n \tif (take_worktree_changes && !add_renormalize && !ignore_add_errors &&\n \t    report_path_error(ps_matched, &pathspec))\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex f9453473fe..88d6a68022 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -899,7 +899,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\t\t */\n \n \t\t\tadd_files_to_cache(the_repository, NULL, NULL, NULL, 0,\n-\t\t\t\t\t   0);\n+\t\t\t\t\t0, 0);\n \t\t\tinit_ui_merge_options(&o, the_repository);\n \t\t\to.verbosity = 0;\n \t\t\twork = write_in_core_index_as_tree(the_repository);\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 0243f17d53..1a00642090 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -455,7 +455,7 @@ static const char *prepare_index(const char **argv, const char *prefix,\n \t\trepo_hold_locked_index(the_repository, &index_lock,\n \t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\tadd_files_to_cache(the_repository, also ? prefix : NULL,\n-\t\t\t\t   &pathspec, ps_matched, 0, 0);\n+\t\t\t\t   &pathspec, ps_matched, 0, 0, 0 );\n \t\tif (!all && report_path_error(ps_matched, &pathspec))\n \t\t\texit(128);\n \ndiff --git a/read-cache-ll.h b/read-cache-ll.h\nindex 71b49d9af4..2c8b4b21b1 100644\n--- a/read-cache-ll.h\n+++ b/read-cache-ll.h\n@@ -481,7 +481,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags);\n+\t\t       int include_sparse, int flags, int ignored_too );\n \n void overlay_tree_on_index(struct index_state *istate,\n \t\t\t   const char *tree_name, const char *prefix);\ndiff --git a/read-cache.c b/read-cache.c\nindex 032480d0c7..0f4981d79f 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -3881,9 +3881,12 @@ void overlay_tree_on_index(struct index_state *istate,\n \n struct update_callback_data {\n \tstruct index_state *index;\n+\tstruct repository *repo;\n+\tstruct pathspec *pathspec;\n \tint include_sparse;\n \tint flags;\n \tint add_errors;\n+\tint ignored_too;\n };\n \n static int fix_unmerged_status(struct diff_filepair *p,\n@@ -3925,7 +3928,7 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tdefault:\n \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n \t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n \t\t\t\t\tdie(_(\"updating files failed\"));\n@@ -3946,7 +3949,7 @@ static void update_callback(struct diff_queue_struct *q,\n \n int add_files_to_cache(struct repository *repo, const char *prefix,\n \t\t       const struct pathspec *pathspec, char *ps_matched,\n-\t\t       int include_sparse, int flags)\n+\t\t       int include_sparse, int flags, int ignored_too )\n {\n \tstruct odb_transaction *transaction;\n \tstruct update_callback_data data;\n@@ -3956,6 +3959,9 @@ int add_files_to_cache(struct repository *repo, const char *prefix,\n \tdata.index = repo->index;\n \tdata.include_sparse = include_sparse;\n \tdata.flags = flags;\n+\tdata.repo = repo;\n+\tdata.ignored_too = ignored_too;\n+\tdata.pathspec = (struct pathspec *)pathspec;\n \n \trepo_init_revisions(repo, &rev, prefix);\n \tsetup_revisions(0, NULL, &rev, NULL);\n-- \ngitgitgadget\n\n"},{"id":"535336","messageId":"504edcb0f522f18cb5586bb47bd2bbaf7c3adffb.1770384180.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","subject":"[PATCH v4 2/5] read-cache: submodule add need --force given ignore=all configuration","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-06T13:22:57Z","receivedAt":"2026-02-06T13:23:06Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nSubmodules configured with ignore=all are now skipped during add operations\nunless overridden by --force and the submodule path is explicitly specified.\n\nA message is printed (like ignored files) guiding the user to use the\n--force flag if the user explicitly wants to update the submodule reference.\n\nThe reason for the change is to support branch tracking in submodules\nwith configuration `submdule.<name>.branch` or similar workflows where the\nuser is not interested in tracking each update of the sha1 in the submdule.\nYou can additionally set `submodule.<name>.ignore=all` and the `git status`\nwill state nothing and, with this patch, the `git add` does not either - as\nthe default behaviour. This patch changes the workflow to a more logical\nbehaviour and similar to workflow for ignored files.\n\nThe patch gives more scenarios for submodules to be used effectively with\nless friction similar to the \"repo\" tool. A submodule can be added for many\ndifferent reasons than a hard dependency. It can be added as loosely\ncoupled dependencies whereas the user wants the latest based on the\nconfiguration `submoule.<name>.branch`, but are not interested to track\neach commit in the `super-repo`. Currently it gives friction of handling\nconflicts between branches even the sha1's are fast-forward and the user\njust wants the latest in any way. The user can still add a sha1 explicitly\nto track updates.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n read-cache.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 71 insertions(+), 3 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 0f4981d79f..cc79b25f43 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -47,6 +47,9 @@\n #include \"csum-file.h\"\n #include \"promisor-remote.h\"\n #include \"hook.h\"\n+#include \"submodule.h\"\n+#include \"submodule-config.h\"\n+#include \"advice.h\"\n \n /* Mask for the name length in ce_flags in the on-disk index */\n \n@@ -3910,8 +3913,68 @@ static int fix_unmerged_status(struct diff_filepair *p,\n \t\treturn DIFF_STATUS_MODIFIED;\n }\n \n+static int skip_submodule(const char *path,\n+\t\t\t\t\t\tstruct repository *repo,\n+\t\t\t\t\t\tstruct pathspec *pathspec,\n+\t\t\t\t\t\tint ignored_too)\n+{\n+    struct stat st;\n+    const struct submodule *sub;\n+    int pathspec_matches = 0;\n+    int ps_i;\n+    char *norm_pathspec = NULL;\n+\n+    /* Only consider if path is a directory */\n+    if (lstat(path, &st) || !S_ISDIR(st.st_mode))\n+\t\treturn 0;\n+\n+    /* Check if it's a submodule with ignore=all */\n+    sub = submodule_from_path(repo, null_oid(the_hash_algo), path);\n+    if (!sub || !sub->name || !sub->ignore || strcmp(sub->ignore, \"all\"))\n+\t\treturn 0;\n+\n+    trace_printf(\"ignore=all: %s\\n\", path);\n+    trace_printf(\"pathspec %s\\n\", (pathspec && pathspec->nr)\n+\t\t\t\t\t\t\t\t\t? \"has pathspec\"\n+\t\t\t\t\t\t\t\t\t: \"no pathspec\");\n+\n+    /* Check if submodule path is explicitly mentioned in pathspec */\n+    if (pathspec) {\n+\t\tfor (ps_i = 0; ps_i < pathspec->nr; ps_i++) {\n+\t\t\tconst char *m = pathspec->items[ps_i].match;\n+\t\t\tif (!m)\n+\t\t\t\tcontinue;\n+\t\t\tnorm_pathspec = xstrdup(m);\n+\t\t\tstrip_dir_trailing_slashes(norm_pathspec);\n+\t\t\tif (!strcmp(path, norm_pathspec)) {\n+\t\t\t\tpathspec_matches = 1;\n+\t\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tFREE_AND_NULL(norm_pathspec);\n+\t\t}\n+    }\n+\n+    /* If explicitly matched and forced, allow adding */\n+    if (pathspec_matches) {\n+\t\tif (ignored_too && ignored_too > 0) {\n+\t\t\ttrace_printf(\"Add submodule due to --force: %s\\n\", path);\n+\t\t\treturn 0;\n+\t\t} else {\n+\t\t\tadvise_if_enabled(ADVICE_ADD_IGNORED_FILE,\n+\t\t\t\t_(\"Skipping submodule due to ignore=all: %s\\n\"\n+\t\t\t\t\t\"Use --force if you really want to add the submodule.\"), path);\n+\t\t\treturn 1;\n+\t\t}\n+    }\n+\n+    /* No explicit pathspec match -> skip silently */\n+    trace_printf(\"Pathspec to submodule does not match explicitly: %s\\n\", path);\n+    return 1;\n+}\n+\n static void update_callback(struct diff_queue_struct *q,\n-\t\t\t    struct diff_options *opt UNUSED, void *cbdata)\n+\t\t\t\t\t\t\tstruct diff_options *opt UNUSED, void *cbdata)\n {\n \tint i;\n \tstruct update_callback_data *data = cbdata;\n@@ -3921,14 +3984,19 @@ static void update_callback(struct diff_queue_struct *q,\n \t\tconst char *path = p->one->path;\n \n \t\tif (!data->include_sparse &&\n-\t\t    !path_in_sparse_checkout(path, data->index))\n+\t\t\t!path_in_sparse_checkout(path, data->index))\n \t\t\tcontinue;\n \n \t\tswitch (fix_unmerged_status(p, data)) {\n \t\tdefault:\n \t\t\tdie(_(\"unexpected diff status %c\"), p->status);\n \t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED: {\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\t\tif (skip_submodule(path, data->repo,\n+\t\t\t\t\t\t\t\tdata->pathspec,\n+\t\t\t\t\t\t\t\tdata->ignored_too))\n+\t\t\t\tcontinue;\n+\n \t\t\tif (add_file_to_index(data->index, path, data->flags)) {\n \t\t\t\tif (!(data->flags & ADD_CACHE_IGNORE_ERRORS))\n \t\t\t\t\tdie(_(\"updating files failed\"));\n-- \ngitgitgadget\n\n"},{"id":"535337","messageId":"d5ea8eb6e0f645fd06316f469a64c22e16a8e281.1770384180.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","subject":"[PATCH v4 3/5] tests: t2206-add-submodule-ignored: ignore=all and add --force tests","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-06T13:22:58Z","receivedAt":"2026-02-06T13:23:08Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThe tests verify that the submodule behavior is intact and updating the\nconfig with ignore=all also behaves as intended with configuration in\n.gitmodules and configuration given on the command line.\n\nThe usage of --force is showcased and tested in the test suite.\n\nThe test file is added to meson.build for execution.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/meson.build                    |   1 +\n t/t2206-add-submodule-ignored.sh | 134 +++++++++++++++++++++++++++++++\n 2 files changed, 135 insertions(+)\n create mode 100755 t/t2206-add-submodule-ignored.sh\n\ndiff --git a/t/meson.build b/t/meson.build\nindex a5531df415..a7d3e3e0a2 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -290,6 +290,7 @@ integration_tests = [\n   't2203-add-intent.sh',\n   't2204-add-ignored.sh',\n   't2205-add-worktree-config.sh',\n+  't2206-add-submodule-ignored.sh',\n   't2300-cd-to-toplevel.sh',\n   't2400-worktree-add.sh',\n   't2401-worktree-prune.sh',\ndiff --git a/t/t2206-add-submodule-ignored.sh b/t/t2206-add-submodule-ignored.sh\nnew file mode 100755\nindex 0000000000..e581e87ab2\n--- /dev/null\n+++ b/t/t2206-add-submodule-ignored.sh\n@@ -0,0 +1,134 @@\n+#!/bin/sh\n+# shellcheck disable=SC2016\n+\n+# shellcheck disable=SC2034\n+test_description='git add respects submodule ignore=all and explicit pathspec'\n+\n+# This test covers the behavior of \"git add\", \"git status\" and \"git log\" when\n+# dealing with submodules that have the ignore=all setting in\n+# .gitmodules. It ensures that changes in such submodules are\n+# ignored by default, but can be staged with \"git add --force\".\n+\n+# shellcheck disable=SC1091\n+. ./test-lib.sh\n+\n+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n+base_path=$(pwd -P)\n+\n+#1\n+test_expect_success 'setup: create origin repos'  '\n+\tcd \"${base_path}\" &&\n+\tgit config --global protocol.file.allow always &&\n+\tgit init sub &&\n+\t\tpwd &&\n+\t\tcd sub &&\n+\t\ttest_commit sub_file1 &&\n+\t\tgit tag v1.0 &&\n+\t\ttest_commit sub_file2 &&\n+\t\tgit tag v2.0 &&\n+\t\ttest_commit sub_file3 &&\n+\t\tgit tag v3.0 &&\n+\tcd \"${base_path}\" &&\n+\tgit init main &&\n+\t\tcd main &&\n+\t\ttest_commit first &&\n+\tcd \"${base_path}\"\n+'\n+#2\n+# add submodule with default config (ignore=none) and\n+# check log that is contains a path entry for the submodule 'sub'\n+# change the commit in the submodule and check that 'git status' shows it as modified\n+test_expect_success 'main: add submodule with default config'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit submodule add ../sub &&\n+\tgit commit -m \"add submodule\" &&\n+\tgit log --oneline --name-only | grep \"^sub$\" &&\n+\tgit -C sub reset --hard v2.0 &&\n+\tgit status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+#3\n+# change the submodule config to ignore=all and check that status and log do not show changes\n+test_expect_success 'main: submodule config ignore=all'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit config -f .gitmodules submodule.sub.ignore all &&\n+\tGIT_TRACE=1 git add . &&\n+\tgit commit -m \"update submodule config sub.ignore all\" &&\n+\t! git status --porcelain | grep \"^.*$\" &&\n+\t! git log --oneline --name-only | grep \"^sub$\" &&\n+\techo\n+'\n+#4\n+# change the commit in the submodule and check that 'git status' does not show it as modified\n+# but 'git status --ignore-submodules=none' does show it as modified\n+test_expect_success 'sub: change to different sha1 and check status in main'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tgit -C sub reset --hard v1.0 &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit status --ignore-submodules=none --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#5\n+# check that normal 'git add' does not stage the change in the submodule\n+test_expect_success 'main: check normal add and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add . &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\techo\n+'\n+\n+#6\n+# check that 'git add --force .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check --force add . and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add --force . &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#7\n+# check that 'git add .' does not stage the change in the submodule\n+# and that 'git status' does not show it as modified\n+test_expect_success 'main: check _add sub_ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\tGIT_TRACE=1 git add sub 2>&1 | grep \"Skipping submodule due to ignore=all: sub\" &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo\n+'\n+\n+#8\n+# check that 'git add --force sub' does stage the change in the submodule\n+# check that 'git add --force ./sub/' does stage the change in the submodule\n+# and that 'git status --porcelain' does show it as modified\n+# commit it..\n+# check that 'git log --ignore-submodules=none' shows the submodule change\n+# in the log\n+test_expect_success 'main: check force add sub and ./sub/ and status'  '\n+\tcd \"${base_path}\" &&\n+\tcd main &&\n+\techo \"Adding with --force should work: git add --force sub\" &&\n+\tGIT_TRACE=1 git add --force sub &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit restore --staged sub &&\n+\t! git status --porcelain | grep \"^M  sub$\" &&\n+\techo \"Adding with --force should work: git add --force ./sub/\" &&\n+\tGIT_TRACE=1 git add --force ./sub/ &&\n+\tgit status --porcelain | grep \"^M  sub$\" &&\n+\tgit commit -m \"update submodule pointer\" &&\n+\t! git status --porcelain | grep \"^ M sub$\" &&\n+\tgit log --ignore-submodules=none --name-only --oneline | grep \"^sub$\" &&\n+\techo\n+'\n+\n+test_done\n+exit 0\n-- \ngitgitgadget\n\n"},{"id":"535338","messageId":"df5c85d9f2a90da9b0ed0c5e70ba4abe08c9d31e.1770384180.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","subject":"[PATCH v4 4/5] tests: fix existing tests when add an ignore=all submodule","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-06T13:22:59Z","receivedAt":"2026-02-06T13:23:09Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\nThere are tests that rely on \"git add <submodule>\" to update the in the\nreference in the parent repository which have been updated to use the\n--force option.\n\nUpdated tests:\n- t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )\n- t7406-submodule-update.sh\n- t7508-status.sh\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n t/lib-submodule-update.sh | 6 +++---\n t/t7508-status.sh         | 2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex 36f767cb74..f591de6120 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -95,14 +95,14 @@ create_lib_submodule_repo () {\n \t\t\tgit commit -m \"modified file2 and added file3\" &&\n \t\t\tgit push origin modifications\n \t\t) &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -m \"Modify sub1\" &&\n \n \t\tgit checkout -b add_nested_sub modify_sub1 &&\n \t\tgit -C sub1 checkout -b \"add_nested_sub\" &&\n \t\tgit -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 &&\n \t\tgit -C sub1 commit -a -m \"add a nested submodule\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -a -m \"update submodule, that updates a nested submodule\" &&\n \t\tgit checkout -b modify_sub1_recursively &&\n \t\tgit -C sub1 checkout -b modify_sub1_recursively &&\n@@ -112,7 +112,7 @@ create_lib_submodule_repo () {\n \t\tgit -C sub1/sub2 commit -m \"make a change in nested sub\" &&\n \t\tgit -C sub1 add sub2 &&\n \t\tgit -C sub1 commit -m \"update nested sub\" &&\n-\t\tgit add sub1 &&\n+\t\tgit add --force sub1 &&\n \t\tgit commit -m \"update sub1, that updates nested sub\" &&\n \t\tgit -C sub1 push origin modify_sub1_recursively &&\n \t\tgit -C sub1/sub2 push origin modify_sub1_recursively &&\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex abad229e9d..a5e21bf8bf 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1576,7 +1576,7 @@ test_expect_success 'git commit will commit a staged but ignored submodule' '\n \n test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '\n \tgit reset HEAD^ &&\n-\tgit add sm &&\n+\tgit add --force sm &&\n \tcat >expect << EOF &&\n On branch main\n Your branch and '\\''upstream'\\'' have diverged,\n-- \ngitgitgadget\n\n"},{"id":"535339","messageId":"8bfaa14d44e224c5f8a3cfe1a0c55e9ca9415a98.1770384180.git.gitgitgadget@gmail.com","threadId":"64349","inReplyTo":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","subject":"[PATCH v4 5/5] Documentation: update add --force option + ignore=all config","fromName":"Claus Schneider(Eficode) via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-06T13:23:00Z","receivedAt":"2026-02-06T13:23:11Z","isPatch":true,"sender":{"key":"name:Claus Schneider(Eficode)","avatar":null},"body":"From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n\n- git-add.adoc: Update the --force documentation for submodule behaviour\n  to be added even the given configuration ignore=all.\n- gitmodules.adoc and config/submodule.adoc: The submodule config\n  ignore=all now need --force in order to update the index.\n\nSigned-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n---\n Documentation/config/submodule.adoc | 13 +++++++------\n Documentation/git-add.adoc          |  5 ++++-\n Documentation/gitmodules.adoc       |  5 ++++-\n 3 files changed, 15 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config/submodule.adoc b/Documentation/config/submodule.adoc\nindex 0672d99117..b3db1dc2c8 100644\n--- a/Documentation/config/submodule.adoc\n+++ b/Documentation/config/submodule.adoc\n@@ -32,15 +32,16 @@ submodule.<name>.fetchRecurseSubmodules::\n \n submodule.<name>.ignore::\n \tDefines under what circumstances \"git status\" and the diff family show\n-\ta submodule as modified. When set to \"all\", it will never be considered\n-\tmodified (but it will nonetheless show up in the output of status and\n-\tcommit when it has been staged), \"dirty\" will ignore all changes\n-\tto the submodule's work tree and\n+\ta submodule as modified.\n+\tWhen set to \"all\" will never consider the submodule modified. It can\n+\tnevertheless be staged using the option --force and it will then show up\n+\tin the output of status.\n+\tWhen set to \"dirty\" will ignore all changes to the submodule's work tree and\n \ttakes only differences between the HEAD of the submodule and the commit\n \trecorded in the superproject into account. \"untracked\" will additionally\n \tlet submodules with modified tracked files in their work tree show up.\n-\tUsing \"none\" (the default when this option is not set) also shows\n-\tsubmodules that have untracked files in their work tree as changed.\n+\tWhen set to \"none\"(default) It also show submodules as changed if they have\n+\tuntracked files in their work tree.\n \tThis setting overrides any setting made in .gitmodules for this submodule,\n \tboth settings can be overridden on the command line by using the\n \t\"--ignore-submodules\" option. The 'git submodule' commands are not\ndiff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\nindex 6192daeb03..941135dc63 100644\n--- a/Documentation/git-add.adoc\n+++ b/Documentation/git-add.adoc\n@@ -75,7 +75,10 @@ in linkgit:gitglossary[7].\n \n `-f`::\n `--force`::\n-\tAllow adding otherwise ignored files.\n+\tAllow adding otherwise ignored files. The option is also used when\n+\t`submodule.<name>.ignore=all` is set, but you want to stage an\n+\tupdate of the submodule. The `path` to the submodule must be explicitly\n+\tspecified.\n \n `--sparse`::\n \tAllow updating index entries outside of the sparse-checkout cone.\ndiff --git a/Documentation/gitmodules.adoc b/Documentation/gitmodules.adoc\nindex d9bec8b187..3792da96aa 100644\n--- a/Documentation/gitmodules.adoc\n+++ b/Documentation/gitmodules.adoc\n@@ -70,7 +70,10 @@ submodule.<name>.ignore::\n --\n \tall;; The submodule will never be considered modified (but will\n \t    nonetheless show up in the output of status and commit when it has\n-\t    been staged).\n+\t    been staged). Add `(new commits)` can be overruled using the\n+\t    `git add --force <submodule.path>`.\n+\t\tThe setting affects `status`, `update-index`, `diff` and `log`(due\n+\t\tto underlaying `diff`).\n \n \tdirty;; All changes to the submodule's work tree will be ignored, only\n \t    committed differences between the `HEAD` of the submodule and its\n-- \ngitgitgadget\n"},{"id":"535492","messageId":"xmqq7bsm93o4.fsf@gitster.g","threadId":"64349","inReplyTo":"69e0065b1bfe469c25f023592a5a6600d49348dc.1770384180.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/5] read-cache: update add_files_to_cache take param ignored_too","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-09T00:11:23Z","receivedAt":"2026-02-09T00:11:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Claus Schneider(Eficode) via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n>\n> The ignored_too parameter is added to the function\n> add_files_to_cache for usage of explicit updating the index for the updated\n> submodule using the explicit patchspec to the submodule.\n>\n> Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n\nNot about the patch at all, and not a complaint at all, but an\nobservation.\n\nYour sign-off is given without a space before \"(EFicode)\" here,\nwhile the previous iteration has a space there.  It seems that your\nauthor identity has been without the space, so this change makes it\nconsistent between the two.\n"},{"id":"535493","messageId":"xmqq5x8693nz.fsf@gitster.g","threadId":"64349","inReplyTo":"69e0065b1bfe469c25f023592a5a6600d49348dc.1770384180.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/5] read-cache: update add_files_to_cache take param ignored_too","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-09T00:11:28Z","receivedAt":"2026-02-09T00:11:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Claus Schneider(Eficode) via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n>\n> The ignored_too parameter is added to the function\n> add_files_to_cache for usage of explicit updating the index for the updated\n> submodule using the explicit patchspec to the submodule.\n>\n> Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n\nNot about the patch at all, and not a complaint at all, but an\nobservation.\n\nYour sign-off is given without a space before \"(EFicode)\" here,\nwhile the previous iteration has a space there.  It seems that your\nauthor identity has been without the space, so this change makes it\nconsistent between the two.\n"},{"id":"536554","messageId":"xmqq5x7rvyn4.fsf@gitster.g","threadId":"64349","inReplyTo":"pull.1987.v4.git.1770384180.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 0/5] git-add: Skip submodules with ignore=all unless --force and explicit path used","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-20T22:27:43Z","receivedAt":"2026-02-20T22:27:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Claus Schneider via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> The ignore=all configuration for submodules is currently honored by status\n> and diff, but not by add. This inconsistency causes friction when working\n> with submodules:\n>\n>  * Developers unintentionally stage submodule updates, leading to conflicts\n>    and unnecessary changes.\n>  * Tracking branches in submodule configs causes friction as updates to the\n>    submodule SHA1 are added without intent.\n>\n> This patch aligns git add with the behavior of status and diff:\n>\n>  * Submodules marked ignore=all are skipped by default.\n>  * Attempting to add such a submodule explicitly now requires --force.\n>\n> A submodule can frictionless track a branch in the configuration or manually\n> switched to and use update --update --remote without unintentionally add the\n> changes to the super-project.\n>\n> Tests that previously added submodules without --force have been updated\n> accordingly. A new test is added to test the behavior of git add with and\n> without --force.\n\nThe latest round of this series has not seen any meaningful reviews.\nEverybody happy with this latest round?\n\nThanks.\n"},{"id":"537779","messageId":"faf8622b-b960-4f58-add7-28b5e081afb3@app.fastmail.com","threadId":"64349","inReplyTo":"8bfaa14d44e224c5f8a3cfe1a0c55e9ca9415a98.1770384180.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 5/5] Documentation: update add --force option + ignore=all config","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-03-04T14:01:48Z","receivedAt":"2026-03-04T14:02:09Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Fri, Feb 6, 2026, at 14:23, Claus Schneider(Eficode) via GitGitGadget wrote:\n> From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n>\n> - git-add.adoc: Update the --force documentation for submodule behaviour\n>   to be added even the given configuration ignore=all.\n> - gitmodules.adoc and config/submodule.adoc: The submodule config\n>   ignore=all now need --force in order to update the index.\n>\n> Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n>[snip]\n>  \tall;; The submodule will never be considered modified (but will\n>  \t    nonetheless show up in the output of status and commit when it has\n> -\t    been staged).\n> +\t    been staged). Add `(new commits)` can be overruled using the\n> +\t    `git add --force <submodule.path>`.\n> +\t\tThe setting affects `status`, `update-index`, `diff` and `log`(due\n\nThis is in `next` but: should be a space: “`log` (due”.\n\n> +\t\tto underlaying `diff`).\n\ns/underlaying/underlying/ ?\n\n>\n>  \tdirty;; All changes to the submodule's work tree will be ignored, only\n>  \t    committed differences between the `HEAD` of the submodule and its\n> --\n> gitgitgadget\n"},{"id":"538524","messageId":"CA+GP4brEROn5jhmtjW7gwk87hi8T23voyG+LEx-ypwUE0Q5F=w@mail.gmail.com","threadId":"64349","inReplyTo":"faf8622b-b960-4f58-add7-28b5e081afb3@app.fastmail.com","subject":"Re: [PATCH v4 5/5] Documentation: update add --force option + ignore=all config","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2026-03-10T21:04:17Z","receivedAt":"2026-03-10T21:04:29Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Hi ..\n\nThanks .. I will fix both.\n\nBr\nClaus Schneider\n\nOn Wed, Mar 4, 2026 at 3:02 PM Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> On Fri, Feb 6, 2026, at 14:23, Claus Schneider(Eficode) via GitGitGadget wrote:\n> > From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n> >\n> > - git-add.adoc: Update the --force documentation for submodule behaviour\n> >   to be added even the given configuration ignore=all.\n> > - gitmodules.adoc and config/submodule.adoc: The submodule config\n> >   ignore=all now need --force in order to update the index.\n> >\n> > Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> >[snip]\n> >       all;; The submodule will never be considered modified (but will\n> >           nonetheless show up in the output of status and commit when it has\n> > -         been staged).\n> > +         been staged). Add `(new commits)` can be overruled using the\n> > +         `git add --force <submodule.path>`.\n> > +             The setting affects `status`, `update-index`, `diff` and `log`(due\n>\n> This is in `next` but: should be a space: “`log` (due”.\n>\n> > +             to underlaying `diff`).\n>\n> s/underlaying/underlying/ ?\n>\n> >\n> >       dirty;; All changes to the submodule's work tree will be ignored, only\n> >           committed differences between the `HEAD` of the submodule and its\n> > --\n> > gitgitgadget\n"},{"id":"538527","messageId":"CA+GP4bqf6=Lv3esMxorhbn6J9AMT-A4cEyhgpnm8iLUd+Myz0Q@mail.gmail.com","threadId":"64349","inReplyTo":"CA+GP4brEROn5jhmtjW7gwk87hi8T23voyG+LEx-ypwUE0Q5F=w@mail.gmail.com","subject":"Re: [PATCH v4 5/5] Documentation: update add --force option + ignore=all config","fromName":"Claus Schneider","fromEmail":"claus.schneider@eficode.com","sentAt":"2026-03-10T21:10:14Z","receivedAt":"2026-03-10T21:10:26Z","isPatch":true,"sender":{"key":"claus.schneider@eficode.com","avatar":"https://avatars.githubusercontent.com/u/3347017?v=4"},"body":"Hi Kristoffer,\n\nI am unsure about submitting these fixes now, as the patch appears to\nhave already been merged.\n\nI could add it as a 6th patch, and merging would still work fine\ninstead of amending the 5th patch - please let me know what is the\nbest way to proceed\n\nBest regards,\nClaus Schneider\n\nOn Tue, Mar 10, 2026 at 10:04 PM Claus Schneider\n<claus.schneider@eficode.com> wrote:\n>\n> Hi ..\n>\n> Thanks .. I will fix both.\n>\n> Br\n> Claus Schneider\n>\n> On Wed, Mar 4, 2026 at 3:02 PM Kristoffer Haugsbakk\n> <kristofferhaugsbakk@fastmail.com> wrote:\n> >\n> > On Fri, Feb 6, 2026, at 14:23, Claus Schneider(Eficode) via GitGitGadget wrote:\n> > > From: \"Claus Schneider(Eficode)\" <claus.schneider@eficode.com>\n> > >\n> > > - git-add.adoc: Update the --force documentation for submodule behaviour\n> > >   to be added even the given configuration ignore=all.\n> > > - gitmodules.adoc and config/submodule.adoc: The submodule config\n> > >   ignore=all now need --force in order to update the index.\n> > >\n> > > Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>\n> > >[snip]\n> > >       all;; The submodule will never be considered modified (but will\n> > >           nonetheless show up in the output of status and commit when it has\n> > > -         been staged).\n> > > +         been staged). Add `(new commits)` can be overruled using the\n> > > +         `git add --force <submodule.path>`.\n> > > +             The setting affects `status`, `update-index`, `diff` and `log`(due\n> >\n> > This is in `next` but: should be a space: “`log` (due”.\n> >\n> > > +             to underlaying `diff`).\n> >\n> > s/underlaying/underlying/ ?\n> >\n> > >\n> > >       dirty;; All changes to the submodule's work tree will be ignored, only\n> > >           committed differences between the `HEAD` of the submodule and its\n> > > --\n> > > gitgitgadget\n"}]}