@ -168,7 +168,6 @@ public class IndexDiff {
* @throws IOException
* @throws IOException
* /
* /
public boolean diff ( ) throws IOException {
public boolean diff ( ) throws IOException {
boolean changesExist = false ;
dirCache = repository . readDirCache ( ) ;
dirCache = repository . readDirCache ( ) ;
TreeWalk treeWalk = new TreeWalk ( repository ) ;
TreeWalk treeWalk = new TreeWalk ( repository ) ;
@ -202,12 +201,10 @@ public class IndexDiff {
! = dirCacheIterator . getEntryRawMode ( ) ) {
! = dirCacheIterator . getEntryRawMode ( ) ) {
// in repo, in index, content diff => changed
// in repo, in index, content diff => changed
changed . add ( treeWalk . getPathString ( ) ) ;
changed . add ( treeWalk . getPathString ( ) ) ;
changesExist = true ;
}
}
} else {
} else {
// in repo, not in index => removed
// in repo, not in index => removed
removed . add ( treeWalk . getPathString ( ) ) ;
removed . add ( treeWalk . getPathString ( ) ) ;
changesExist = true ;
if ( workingTreeIterator ! = null )
if ( workingTreeIterator ! = null )
untracked . add ( treeWalk . getPathString ( ) ) ;
untracked . add ( treeWalk . getPathString ( ) ) ;
}
}
@ -215,13 +212,11 @@ public class IndexDiff {
if ( dirCacheIterator ! = null ) {
if ( dirCacheIterator ! = null ) {
// not in repo, in index => added
// not in repo, in index => added
added . add ( treeWalk . getPathString ( ) ) ;
added . add ( treeWalk . getPathString ( ) ) ;
changesExist = true ;
} else {
} else {
// not in repo, not in index => untracked
// not in repo, not in index => untracked
if ( workingTreeIterator ! = null
if ( workingTreeIterator ! = null
& & ! workingTreeIterator . isEntryIgnored ( ) ) {
& & ! workingTreeIterator . isEntryIgnored ( ) ) {
untracked . add ( treeWalk . getPathString ( ) ) ;
untracked . add ( treeWalk . getPathString ( ) ) ;
changesExist = true ;
}
}
}
}
}
}
@ -230,18 +225,22 @@ public class IndexDiff {
if ( workingTreeIterator = = null ) {
if ( workingTreeIterator = = null ) {
// in index, not in workdir => missing
// in index, not in workdir => missing
missing . add ( treeWalk . getPathString ( ) ) ;
missing . add ( treeWalk . getPathString ( ) ) ;
changesExist = true ;
} else {
} else {
if ( workingTreeIterator . isModified (
if ( workingTreeIterator . isModified (
dirCacheIterator . getDirCacheEntry ( ) , true ) ) {
dirCacheIterator . getDirCacheEntry ( ) , true ) ) {
// in index, in workdir, content differs => modified
// in index, in workdir, content differs => modified
modified . add ( treeWalk . getPathString ( ) ) ;
modified . add ( treeWalk . getPathString ( ) ) ;
changesExist = true ;
}
}
}
}
}
}
}
}
return changesExist ;
if ( added . isEmpty ( ) & & changed . isEmpty ( ) & & removed . isEmpty ( )
& & missing . isEmpty ( ) & & modified . isEmpty ( )
& & untracked . isEmpty ( ) )
return false ;
else
return true ;
}
}
/ * *
/ * *