From c9e4a78555e828e5eecaa6fb0d89b7b460cab48b Mon Sep 17 00:00:00 2001 From: Jens Baumgart Date: Wed, 9 Feb 2011 15:02:22 +0100 Subject: Add isOutdated method to DirCache isOutdated returns true iff the memory state differs from the index file. Change-Id: If35db06743f5f588ab19d360fd2a18a07c918edb Signed-off-by: Jens Baumgart --- org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 143447c8d6..c2c57c9840 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -312,6 +312,16 @@ public class DirCache { } } + /** + * @return true if the memory state differs from the index file + * @throws IOException + */ + public boolean isOutdated() throws IOException { + if (liveFile == null || !liveFile.exists()) + return false; + return liveFile.lastModified() != lastModified; + } + /** Empty this index, removing all entries. */ public void clear() { lastModified = 0; -- cgit v1.2.3