This is sadly going to force us to keep the bulk of this revision pool alive longer than we need to.

Can we instead do:

  unshallowCommits.add(walk.lookupCommit(c));

This way what we hold onto is a pointer into the main pool we already are retaining long-term.  Or maybe better, since these two collections don't actually have to be RevCommits we can just declare them ObjectId and use:

  unshallowCommits.add(c.copy));

to shed the entire pool overhead.