@ -659,11 +659,7 @@ public class RevWalk implements Iterable<RevCommit> {
public RevCommit parseCommit ( final AnyObjectId id )
public RevCommit parseCommit ( final AnyObjectId id )
throws MissingObjectException , IncorrectObjectTypeException ,
throws MissingObjectException , IncorrectObjectTypeException ,
IOException {
IOException {
RevObject c = parseAny ( id ) ;
RevObject c = peel ( parseAny ( id ) ) ;
while ( c instanceof RevTag ) {
c = ( ( RevTag ) c ) . getObject ( ) ;
parseHeaders ( c ) ;
}
if ( ! ( c instanceof RevCommit ) )
if ( ! ( c instanceof RevCommit ) )
throw new IncorrectObjectTypeException ( id . toObjectId ( ) ,
throw new IncorrectObjectTypeException ( id . toObjectId ( ) ,
Constants . TYPE_COMMIT ) ;
Constants . TYPE_COMMIT ) ;
@ -690,11 +686,7 @@ public class RevWalk implements Iterable<RevCommit> {
public RevTree parseTree ( final AnyObjectId id )
public RevTree parseTree ( final AnyObjectId id )
throws MissingObjectException , IncorrectObjectTypeException ,
throws MissingObjectException , IncorrectObjectTypeException ,
IOException {
IOException {
RevObject c = parseAny ( id ) ;
RevObject c = peel ( parseAny ( id ) ) ;
while ( c instanceof RevTag ) {
c = ( ( RevTag ) c ) . getObject ( ) ;
parseHeaders ( c ) ;
}
final RevTree t ;
final RevTree t ;
if ( c instanceof RevCommit )
if ( c instanceof RevCommit )
@ -802,6 +794,29 @@ public class RevWalk implements Iterable<RevCommit> {
obj . parseBody ( this ) ;
obj . parseBody ( this ) ;
}
}
/ * *
* Peel back annotated tags until a non - tag object is found .
*
* @param obj
* the starting object .
* @return If { @code obj } is not an annotated tag , { @code obj } . Otherwise
* the first non - tag object that { @code obj } references . The
* returned object ' s headers have been parsed .
* @throws MissingObjectException
* a referenced object cannot be found .
* @throws IOException
* a pack file or loose object could not be read .
* /
public RevObject peel ( RevObject obj ) throws MissingObjectException ,
IOException {
while ( obj instanceof RevTag ) {
parseHeaders ( obj ) ;
obj = ( ( RevTag ) obj ) . getObject ( ) ;
}
parseHeaders ( obj ) ;
return obj ;
}
/ * *
/ * *
* Create a new flag for application use during walking .
* Create a new flag for application use during walking .
* < p >
* < p >