Jacob Keller <jacob.e.keller@xxxxxxxxx> writes: > From: Jacob Keller <jacob.keller@xxxxxxxxx> > > Teach git diff --no-index the ability to exclude files by wildmatch > pattern when recursing through directories. The '--exclude' option > builds up a string list containing the patterns. These are checked with > wildmatch() in the read_directory_contents function. If any pattern > matches, then the file is not included in the directory contents. A quite natural question that comes to mind is: How would we do this for the normal "git diff" that is not the bolted on '--no-index' mode? but ... > The --exclude option is only supported by the --no-index mode. Standard > diff modes support negative pathspecs which is more powerful. I tried to > see if there was a way to add support for negative pathspecs themselves, > but haven't yet figured out if this is possible. ... of course you have thought about it already. I do agree with you that we should figure out how and teach this mode to also use pathspec, not necessarily only the negative ones but positive ones. After all, $ git diff --no-index [<option>...] dirA dirB is like running $ diff -r [<option>...] dirA dirB after preparing these two directories like so: $ git archive revA | ( mkdir dirA && tar Cxf dirA - ) $ git archive revB | ( mkdir dirB && tar Cxf dirB - ) Hence it is natural for users to expect that anything you can do with $ git diff revA revB should be doable, in $ git diff --no-index dirA dirB and vice versa. And as you said, when comparing two revisions, you'd use pathspec for this kind of thing. $ git diff revA revB -- Documentation/ t/ ':!po/' So, I pretty much agree with the need to be able to exclude some parts of the tree(s) from comparison in "diff --no-index" mode, but I doubt it is a good idea to tell what to exclude the "--no-index" mode in a completely different way. The last time I looked at it, I got an impression that the command line argument parsing of "git diff --no-index" was messy (which is sort of inevitable, since unlike the normal "git diff", it can compare more than just two "collections"---it can take two paths to regular files, for example, and in such a case pathspec arguments can play no role), so teaching it pathspec parsing might be a bit of work, though. Thanks for starting an interesting topic.