Alternative way to write a packfile.

This time it can be done on a per-object basis, and the number of objects is
automatically counted.

This should make it possible to implement the generation of a new packfile
during the traversal of an existing one (the goal would be that each packfile
represents a complete commit/tree, the second one containing only the objects
modified w.r.t. the first one).