libgit2/libgit2 — pull request #1350 by arrbee (2013-02-20 19:07:26+00:00)
Title: Add explicit entrycount to tree builder

I'm trying to clean up PRs. This implements the proposed alternative for PR #1292 that adds an `entrycount` field to the tree builder to maintain an accurate count of the number of entries (since the `removed` flag means that the vector length is not right).

I could not resist adding a second commit with a few `src/tree.c` code cleanups. I isolated all of these cleanups in a separate commit, but I think they are mostly non-controversial:

* Tried to replace most explicit vector iteration with `git_vector_foreach`
* Added call to `giterr_clear()` before any return of `GIT_EUSER`
* Added some `git__free()` of allocated data on some error return paths
* Streamlined structure of `git_treebuilder_write` and `git_tree_walk` functions somewhat