Junio C Hamano <gitster@xxxxxxxxx> writes: > Brandon Williams <bmwill@xxxxxxxxxx> writes: > >> On a similar but slightly different note. In general do we want >> the pathspec '??b' to match against the sib/ directory and >> subsequently have ls-files print all entries inside of the sib/ >> directory? (this is in the non-recursive case) > > I'd need to find time to dig a bit of history before I can give a > firm opinion on this, but here is a knee-jerk version of my reaction. In the context of what you are doing, i.e. "ls-files that recurses into submodules", my opinion is that "ls-files --recurse-submodules" should behave wrt pathspecs AS IF all the submodule contents are flattened into a single index of the superproject. In the sample scenario under discussion, i.e. In the superproject we have these $ git ls-files -s 100644 c489803d5bdec1755f650854fe7ef5ab7a3ee58d 0 .gitmodules 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sib/file 160000 1f5a0695289c500f25e7fa55e3ad27e394d1206b 0 sub In 'sub' submodule we have this 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 file such a flattend index would look like this: 100644 c489803d5bdec1755f650854fe7ef5ab7a3ee58d 0 .gitmodules 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sib/file 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/file i.e. removing 'sub' submodule entry from the index of the superproject and overlay everything in the submodule with sub/ prefixed to its path. And with such an index, if and only if a path matches a pathspec, "git ls-files --recurse-submodules" run at the toplevel with the same pathspec should show the path. That means $ git ls-files --recurse-submodules '??b' would show nothing (not even 'sub'), while $ git ls-files --recurse-submodules '??b*' should show sib/file and sub/file. That is because that is how the command without "--recurse-submodules" working on that flat index would produce. The "we have historically two kinds of pathspecs and they differ how they work with wildcard" is a separate issue, I would think, even though the result would affect what should happen in the above example (i.e. if we said "either a pattern match or a literal match to a leading directory path should make everything underneath match", '??b' would make sib/<anything> and sub/<anything> to be shown).