]> source.dussan.org Git - jgit.git/commitdiff
IndexDiff: Clean up tree-index compare for staged files 73/2073/2
authorShawn O. Pearce <spearce@spearce.org>
Wed, 8 Dec 2010 03:05:07 +0000 (19:05 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 8 Dec 2010 18:03:20 +0000 (10:03 -0800)
When comparing the ObjectIds for two tree entries its faster
to use the raw buffer compares over allocating ObjectIds and
then performing equals on their contents.

However, this also needs to consider the raw modes.  It is possible
for a path to change modes but not ObjectId (e.g. making a file
executable), and in this case its still a staged change to report back
to the caller.

Change-Id: I1a267254c04b3273a97f63c71d1e6718cd9d2fa8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java

index 52fc3db791bd670c4b9a6fe4856c974d3678f915..2ffc54872b111478d1dc79b981ab98c5fbbdcfe7 100644 (file)
@@ -197,8 +197,9 @@ public class IndexDiff {
 
                        if (treeIterator != null) {
                                if (dirCacheIterator != null) {
-                                       if (!treeIterator.getEntryObjectId().equals(
-                                                       dirCacheIterator.getEntryObjectId())) {
+                                       if (!treeIterator.idEqual(dirCacheIterator)
+                                                       || treeIterator.getEntryRawMode()
+                                                       != dirCacheIterator.getEntryRawMode()) {
                                                // in repo, in index, content diff => changed
                                                changed.add(treeWalk.getPathString());
                                                changesExist = true;