libgit2/libgit2 — pull request #706 by arrbee (2012-05-17 00:16:35+00:00)
Title: Fix status for files under ignored dirs

There was a bug where tracked files inside directories that were themselves inside ignored directories where not being found by `git_status_foreach` and hence show up as REMOVED. To explain the situation a little better let me walk through a repo with the problem. If you have a `.gitignore` with:

ignore/

And then have the following files:

ignore/dir/tracked <-- actually a tracked file
ignore/dir/untracked <-- should be ignored

Then we would show the tracked file as being removed (because when we got the to contained item `dir/` inside the ignored directory, we decided it was safe to skip - bzzt, wrong!).

This update is much more careful about checking that we are not skipping over any prefix of a tracked item, regardless of whether it is ignored or not.

It turns out there are some subtleties here. As documented in `diff.c`, this commit creates behavior that still differs from core git with regards to the handling of *untracked* files contained inside ignored directories. With libgit2, those files will just not show up in status or diff. With core git, those files don't show up in status or diff either *unless* they are explicitly ignored by a `.gitignore` pattern in which case they show up as ignored files.

Needless to say, this is a local behavior difference only, so it should not be important and (to me) the libgit2 behavior seems more consistent. The behavior for tracked files is now identical to core git (I believe).

This PR *should* fix issue #592 although we'll probably need @sc68cal to confirm that.