From 475672866a15ff325583e9ccadd9d606d8b66384 Mon Sep 17 00:00:00 2001 From: Philipp Thun Date: Mon, 28 Mar 2011 17:54:24 +0200 Subject: [PATCH] Fix possible NPE in DirCache.isModified() 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 --- org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index 0d8fb7e26..96173b7b4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -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. */