]> source.dussan.org Git - jgit.git/commitdiff
Fix possible NPE in DirCache.isModified() 51/2951/1
authorPhilipp Thun <philipp.thun@sap.com>
Mon, 28 Mar 2011 15:54:24 +0000 (17:54 +0200)
committerPhilipp Thun <philipp.thun@sap.com>
Mon, 28 Mar 2011 15:54:24 +0000 (17:54 +0200)
The snapshot field of a DirCache object for a newly created repository
can be null. This fix prevents a NPE when isModified() is called in
such a situation.

Change-Id: I61a1b45db2d60fdcc0f87373ac6fd75ac4c4a202
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

index 0d8fb7e266c55b119b8eb2a74caa5dd3dc1ac5f6..96173b7b4b09007acb3081ffea299fb678f5df5e 100644 (file)
@@ -321,7 +321,7 @@ public class DirCache {
        public boolean isOutdated() throws IOException {
                if (liveFile == null || !liveFile.exists())
                        return false;
-               return snapshot.isModified(liveFile);
+               return snapshot != null && snapshot.isModified(liveFile);
        }
 
        /** Empty this index, removing all entries. */