title: From a shell script, how can I filter out files matching .gitignore?
body: <p>I'm maintaining some git pre-commit hooks, and I keep wanting to do something for all files that are or should be under revision control.
  Knowing the project structure lets me do a decent job of this, but all the info about build system output directories, test log files, and editor droppings is already in <code>.gitignore</code>.</p>
  
  <p>Is there a simple way to filter file paths based on whether they match a pattern in <code>.gitignore</code>.</p>
  
  <p>Iow, what can I substitute for <code>WHAT GOES HERE</code> in</p>
  
  <pre><code>find "$(git rev-parse --show-toplevel)" --my --filters | WHAT GOES HERE
  </code></pre>
  
  <p>so that I get all and only un-gitignored files that match my filters.</p>
  
  <p>I think I can get a negative filter that I might tee into <code>comm</code> by doing</p>
  
  <pre><code>... | xargs git ls-files -X .gitignore -i
  </code></pre>
  
  <p>but I was hoping for a single step.</p>