Stefan Beller <sbeller@xxxxxxxxxx> writes: The title was ungrokkable to me, but after reading the code I think you are teaching the normal codepath where removal of working tree is done to match what is done to the index that submodules are also in the working tree and need to be removed when the corresopnding ce is removed. Which makes sense. > Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> > --- > read-cache.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/read-cache.c b/read-cache.c > index 9054369dd0..b78a7f02e3 100644 > --- a/read-cache.c > +++ b/read-cache.c > @@ -18,6 +18,7 @@ > #include "varint.h" > #include "split-index.h" > #include "utf8.h" > +#include "submodule.h" > > /* Mask for the name length in ce_flags in the on-disk index */ > > @@ -532,6 +533,8 @@ void remove_marked_cache_entries(struct index_state *istate) > > for (i = j = 0; i < istate->cache_nr; i++) { > if (ce_array[i]->ce_flags & CE_REMOVE) { > + if (is_active_submodule_with_strategy(ce_array[i], SM_UPDATE_UNSPECIFIED)) > + submodule_go_from_to(ce_array[i]->name, "HEAD", NULL, 0, 1); > remove_name_hash(istate, ce_array[i]); > save_or_free_index_entry(istate, ce_array[i]); > }