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