@ -155,16 +155,16 @@ class DiffAlgorithms extends TextBuiltin {
else
else
rb . findGitDir ( dir ) ;
rb . findGitDir ( dir ) ;
Repository db = rb . build ( ) ;
Repository repo = rb . build ( ) ;
try {
try {
run ( db ) ;
run ( repo ) ;
} finally {
} finally {
db . close ( ) ;
repo . close ( ) ;
}
}
}
}
}
}
private void run ( Repository db ) throws Exception {
private void run ( Repository repo ) throws Exception {
List < Test > all = init ( ) ;
List < Test > all = init ( ) ;
long files = 0 ;
long files = 0 ;
@ -173,14 +173,14 @@ class DiffAlgorithms extends TextBuiltin {
int maxN = 0 ;
int maxN = 0 ;
AbbreviatedObjectId startId ;
AbbreviatedObjectId startId ;
try ( ObjectReader or = db . newObjectReader ( ) ;
try ( ObjectReader or = repo . newObjectReader ( ) ;
RevWalk rw = new RevWalk ( or ) ) {
RevWalk rw = new RevWalk ( or ) ) {
final MutableObjectId id = new MutableObjectId ( ) ;
final MutableObjectId id = new MutableObjectId ( ) ;
TreeWalk tw = new TreeWalk ( or ) ;
TreeWalk tw = new TreeWalk ( or ) ;
tw . setFilter ( TreeFilter . ANY_DIFF ) ;
tw . setFilter ( TreeFilter . ANY_DIFF ) ;
tw . setRecursive ( true ) ;
tw . setRecursive ( true ) ;
ObjectId start = db . resolve ( Constants . HEAD ) ;
ObjectId start = repo . resolve ( Constants . HEAD ) ;
startId = or . abbreviate ( start ) ;
startId = or . abbreviate ( start ) ;
rw . markStart ( rw . parseCommit ( start ) ) ;
rw . markStart ( rw . parseCommit ( start ) ) ;
for ( ; ; ) {
for ( ; ; ) {
@ -235,14 +235,15 @@ class DiffAlgorithms extends TextBuiltin {
Collections . sort ( all , new Comparator < Test > ( ) {
Collections . sort ( all , new Comparator < Test > ( ) {
public int compare ( Test a , Test b ) {
public int compare ( Test a , Test b ) {
int cmp = Long . signum ( a . runningTimeNanos - b . runningTimeNanos ) ;
int result = Long . signum ( a . runningTimeNanos - b . runningTimeNanos ) ;
if ( cmp = = 0 )
if ( result = = 0 ) {
cmp = a . algorithm . name . compareTo ( b . algorithm . name ) ;
result = a . algorithm . name . compareTo ( b . algorithm . name ) ;
return cmp ;
}
return result ;
}
}
} ) ;
} ) ;
File directory = db . getDirectory ( ) ;
File directory = repo . getDirectory ( ) ;
if ( directory ! = null ) {
if ( directory ! = null ) {
String name = directory . getName ( ) ;
String name = directory . getName ( ) ;
File parent = directory . getParentFile ( ) ;
File parent = directory . getParentFile ( ) ;