Subject: [PATCH v2 2/5] read-cache: add/read-cache respect submodule ignore=all

From: "Claus Schneider(Eficode) via GitGitGadget" <[email-masked]>
Date: Thu, 13 Nov 2025 18:10:30 +0000

From: "Claus Schneider(Eficode)" <[email-masked]>

Submodules configured with ignore=all are now skipped during add operations
unless overridden by --include-ignored-submodules and the submodule path is
explicitly specified.

A message is printed (like ignored files) guiding the user to use the
--include-ignored-submodules flag if the user has explicitely want to update
the submodule reference.

The reason for the change is support submodule branch tracking or
similar and git status state nothing and git add should not add either.
The workflow is more logic and similar to regular ignored files even
the submodule is already tracked.

The change opens up a lot of possibilities for submodules to be used
more freely and simular to the repo tool. A submodule can be added for many
more reason and loosely coupled dependencies to the super repo which often
gives the friction of handle the explicit commits and updates without
the need for tracking the submodule sha1 by sha1.

Signed-off-by: Claus Schneider(Eficode) <[email-masked]>
---
 read-cache.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 32f32bdb4c..7b6d1b2914 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -48,6 +48,8 @@
 #include "csum-file.h"
 #include "promisor-remote.h"
 #include "hook.h"
+#include "submodule.h"
+#include "submodule-config.h"
 
 /* Mask for the name length in ce_flags in the on-disk index */
 
@@ -3956,7 +3958,7 @@ static void update_callback(struct diff_queue_struct *q,
 					}
 					if (pathspec_matches) {
 						if (data->include_ignored_submodules && data->include_ignored_submodules > 0) {
-							trace_printf("Add ignored=all submodule due to --include_ignored_submodules: %s\n", path);
+							trace_printf("Add submodule due to --include_ignored_submodules: %s\n", path);
 						} else {
 							printf(_("Skipping submodule due to ignore=all: %s"), path);
 							printf(_("Use --include_ignored_submodules, if you really want to add them.") );
@@ -3964,7 +3966,7 @@ static void update_callback(struct diff_queue_struct *q,
 						}
 					} else {
 						/* No explicit pathspec match -> skip silently (or with trace). */
-						trace_printf("pathspec does not match %s\n", path);
+						trace_printf("Pathspec to submodule does not match explicitly: %s\n", path);
 						continue;
 					}
 				}
@@ -3975,6 +3977,7 @@ static void update_callback(struct diff_queue_struct *q,
 				data->add_errors++;
 			}
 			break;
+		}
 		case DIFF_STATUS_DELETED:
 			if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
 				break;
-- 
gitgitgadget