Jeff King [off-list ref] writes:
To be honest, the whole submodule recursion thing seems a bit confusing
to me....
So since we must accept that we can't necessarily get every intermediate
step, I wonder if we are simply better off diffing the "before" and
"after" state of a particular ref, rather than traversing.
Yes, exactly my thought.
It would be far cheaper to look at a single final tree and enumerate all
the submodules, which would give you pessimistically the maximum set that
could possibly be relevant, than running millions of pairwise diff trees.
By the way, I think the submodule traversal won't hurt the correctness of
the primary traversal because that happens _after_ we fetch the object
stream.
The submodule traversal _may_ be getting an incorrect result, though, for
the same reason.