Fix ObjectWalk to handle single-entry subtrees correctly
"jgit push" has been pushing more objects than necessary
for a while now, due to ObjectWalk failing to mark a subtree
uninteresting if it contains exactly one subtree child, such as
"org.spearce.egit.core/src" which has only one child, "org".
The bug was caused by the child iterator being advanced past the
first item before we even evaluated it, as the for loop always
invoked treeWalk.next() at the end of each iteration. However,
a new subtree iterator is positioned on the first item and must
not call next() until after we have handled that first entry.
While debugging this I also noticed strange behavior from the
ObjectWalk evaulating a subtree again, after we had exited it.
This was because the parent iterator was never advanced past the
child when we entered into it. We now advance the parent whenever
we leave the child.
Note that its important we do the parent advance *after* we exit the
child, as they share the same path buffer. Advancing the parent
before we enter into the child would cause the child to corrupt
the parent's next item path.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>