@ -112,6 +112,7 @@ public class NameRevCommand extends GitCommand<Map<ObjectId, String>> {
private final List < String > prefixes ;
private final List < String > prefixes ;
private final List < Ref > refs ;
private final List < Ref > refs ;
private final List < ObjectId > revs ;
private final List < ObjectId > revs ;
private int mergeCost ;
/ * *
/ * *
* Create a new name - rev command .
* Create a new name - rev command .
@ -120,6 +121,7 @@ public class NameRevCommand extends GitCommand<Map<ObjectId, String>> {
* /
* /
protected NameRevCommand ( Repository repo ) {
protected NameRevCommand ( Repository repo ) {
super ( repo ) ;
super ( repo ) ;
mergeCost = MERGE_COST ;
prefixes = new ArrayList < String > ( 2 ) ;
prefixes = new ArrayList < String > ( 2 ) ;
refs = new ArrayList < Ref > ( ) ;
refs = new ArrayList < Ref > ( ) ;
revs = new ArrayList < ObjectId > ( 2 ) ;
revs = new ArrayList < ObjectId > ( 2 ) ;
@ -147,9 +149,9 @@ public class NameRevCommand extends GitCommand<Map<ObjectId, String>> {
break ;
break ;
if ( c . getCommitTime ( ) < cutoff )
if ( c . getCommitTime ( ) < cutoff )
continue ;
continue ;
long cost = c . cost + ( c . getParentCount ( ) > 1 ? MERGE_COST : 1 ) ;
for ( int i = 0 ; i < c . getParentCount ( ) ; i + + ) {
for ( int i = 0 ; i < c . getParentCount ( ) ; i + + ) {
NameRevCommit p = ( NameRevCommit ) walk . parseCommit ( c . getParent ( i ) ) ;
NameRevCommit p = ( NameRevCommit ) walk . parseCommit ( c . getParent ( i ) ) ;
long cost = c . cost + ( i > 0 ? mergeCost : 1 ) ;
if ( p . tip = = null | | compare ( c . tip , cost , p . tip , p . cost ) < 0 ) {
if ( p . tip = = null | | compare ( c . tip , cost , p . tip , p . cost ) < 0 ) {
if ( i > 0 ) {
if ( i > 0 ) {
p . tip = c . format ( ) . append ( '^' ) . append ( i + 1 ) . toString ( ) ;
p . tip = c . format ( ) . append ( '^' ) . append ( i + 1 ) . toString ( ) ;
@ -298,6 +300,11 @@ public class NameRevCommand extends GitCommand<Map<ObjectId, String>> {
return this ;
return this ;
}
}
NameRevCommand setMergeCost ( int cost ) {
mergeCost = cost ;
return this ;
}
private void addPrefixes ( Map < ObjectId , String > nonCommits ,
private void addPrefixes ( Map < ObjectId , String > nonCommits ,
FIFORevQueue pending ) throws IOException {
FIFORevQueue pending ) throws IOException {
if ( ! prefixes . isEmpty ( ) ) {
if ( ! prefixes . isEmpty ( ) ) {