libgit2/libgit2 — pull request #570 by arrbee (2012-02-21 22:58:19+00:00)
Title: Uniform iterators for trees, index, and workdir

This creates a new `git_iterator` type of object that provides a uniform interface for iterating over the index, an arbitrary tree, or the working directory of a repository. It makes all three tree-ish things look like iterating over the index (which seemed like the simplest model of iteration). This code comes out of the refactoring of the git diff code and lays the basis for a greatly cleaned up diff implementation.

As part of this, git ignore support was extended to support push and pop of directory-based ignore files as the working directory is being traversed (so the array of ignores does not have to be recreated at each directory during traveral). At some point, the git ignore code should probably be cleaned up, but this is not the commit to do that.

There are a number of other small utility functions in buffer, path, vector, and fileops that are included in this patch that made the iterator implementation cleaner.

Note to reviewers: It's probably easiest to start with src/iterator.h to get a sense for what the iterator API looks like and then move over to src/iterator.c or peek at the unit tests in tests-clar/diff/iterator.c for usage examples. At some point, if we think it would be useful, we can formalize the iterator API and move it to include/git2, but I wanted to get a little more experience using it before publishing it as a public API.