final ObjectReader reader;
+ private final boolean closeReader;
+
final MutableObjectId idBuffer;
ObjectIdOwnerMap<RevObject> objects;
private int delayFreeFlags;
private int retainOnReset;
+
int carryFlags = UNINTERESTING;
final ArrayList<RevCommit> roots;
*
* @param repo
* the repository the walker will obtain data from. An
- * ObjectReader will be created by the walker, and must be
- * released by the caller.
+ * ObjectReader will be created by the walker, and will be closed
+ * when the walker is closed.
*/
public RevWalk(final Repository repo) {
- this(repo.newObjectReader());
+ this(repo.newObjectReader(), true);
}
/**
* Create a new revision walker for a given repository.
+ * <p>
*
* @param or
- * the reader the walker will obtain data from. The reader should
- * be released by the caller when the walker is no longer
- * required.
+ * the reader the walker will obtain data from. The reader is not
+ * closed when the walker is closed (but is closed by {@link
+ * #dispose()}.
*/
public RevWalk(ObjectReader or) {
+ this(or, false);
+ }
+
+ private RevWalk(ObjectReader or, boolean closeReader) {
reader = or;
idBuffer = new MutableObjectId();
objects = new ObjectIdOwnerMap<RevObject>();
filter = RevFilter.ALL;
treeFilter = TreeFilter.ALL;
retainBody = true;
+ this.closeReader = closeReader;
}
/** @return the reader this walker is using to load objects. */
*/
@Override
public void close() {
- reader.close();
+ if (closeReader) {
+ reader.close();
+ }
}
/**