libgit2/libgit2 — pull request #702 by arrbee (2012-05-15 22:01:09+00:00)
Title: Update git_status_file and add ranged iterators

The goal of this work is to rewrite `git_status_file` to use the same underlying code as `git_status_foreach`.

This is done in 3 pieces:

1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered.
2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration.
3. Rewrite `git_status_file` to call `git_status_foreach_ext` with a pathspec that covers just the one file being checked.

Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient.

The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good. The diff loop at least only processes the one file being examined.

The next efficiency step would be to start and end points to `git_path_dirload_with_stat` which is definitely doable. That would reduce unnecessary stat'ing of files.

There are a few small other cleanups here, too, such as fixing the parameter ordering of the iterator creation APIs (which were not in the correct libgit2 order) and adding a common test for whether a character is an fnmatch wildcard.