Push diff filtering down to shell.

This should make things a little more efficient on the basis of
minimising the amount of data flowing up.