]> source.dussan.org Git - jgit.git/commitdiff
Fix NPE when WorkingTreeIterator does not have a repository set 52/22652/2
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Fri, 28 Feb 2014 06:15:08 +0000 (07:15 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 28 Feb 2014 09:44:54 +0000 (10:44 +0100)
It's strange that we have that member since it is not so clear
when it it set or not.

Change-Id: I53903a264f46866d249901a3cd9f9295028aa6bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.java7.test/src/org/eclipse/jgit/treewalk/FileTreeIteratorJava7Test.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

index 484467b24ca695f3d7fe1d043b5db0ff1e7c4122..2b2d65e9b1590794abd6dcb55f922b1b47147c3f 100644 (file)
@@ -114,7 +114,8 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
                assertEquals("link", dci.getEntryPathString());
 
                // test
-               assertFalse(fti.isModified(dci.getDirCacheEntry(), true));
+               assertFalse(fti.isModified(dci.getDirCacheEntry(), true,
+                               db.newObjectReader()));
        }
 
        /**
@@ -195,6 +196,7 @@ public class FileTreeIteratorJava7Test extends RepositoryTestCase {
                assertEquals("link", dci.getEntryPathString());
 
                // test
-               assertTrue(fti.isModified(dci.getDirCacheEntry(), true));
+               assertTrue(fti.isModified(dci.getDirCacheEntry(), true,
+                               db.newObjectReader()));
        }
 }
index 633865ed4d38779673a4f268bf51def43bd39f50..dd59afc38998b65b4872dde764940c2916ff2f46 100644 (file)
@@ -922,7 +922,8 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
                } else {
                        if (mode == FileMode.SYMLINK.getBits())
                                return !new File(readContentAsNormalizedString(current()))
-                                               .equals(new File((readContentAsNormalizedString(entry))));
+                                               .equals(new File((readContentAsNormalizedString(entry,
+                                                               reader))));
                        // Content differs: that's a real change, perhaps
                        if (reader == null) // deprecated use, do no further checks
                                return true;
@@ -971,9 +972,9 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
                }
        }
 
-       private String readContentAsNormalizedString(DirCacheEntry entry)
-                       throws MissingObjectException, IOException {
-               ObjectLoader open = repository.open(entry.getObjectId());
+       private static String readContentAsNormalizedString(DirCacheEntry entry,
+                       ObjectReader reader) throws MissingObjectException, IOException {
+               ObjectLoader open = reader.open(entry.getObjectId());
                byte[] cachedBytes = open.getCachedBytes();
                return FS.detect().normalize(RawParseUtils.decode(cachedBytes));
        }