From b919a943481a5271aeb2a603c1cac05559e1d354 Mon Sep 17 00:00:00 2001
From: Robin Rosenberg <robin.rosenberg@dewire.com>
Date: Sat, 10 Apr 2010 17:05:36 +0200
Subject: [PATCH] Speed up check for modifications of tracked resources

We only need to check file existense if some other stat returns
a value that may mean that the file does not exist. File.length() == 0
or File.lastModified() == 0 are two such properties. We use length
here.

Change-Id: If626b12e7bb4da994b5c086f6a5b7a12c187261c
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 .../src/org/eclipse/jgit/lib/GitIndex.java             | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java
index 688957b95..4ae24f5e2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java
@@ -567,7 +567,12 @@ public boolean isModified(File wd, boolean forceContentCheck) {
 				return true;
 
 			File file = getFile(wd);
-			if (!file.exists())
+			long length = file.length();
+			if (length == 0) {
+				if (!file.exists())
+					return true;
+			}
+			if (length != size)
 				return true;
 
 			// JDK1.6 has file.canExecute
@@ -600,9 +605,6 @@ public boolean isModified(File wd, boolean forceContentCheck) {
 				}
 			}
 
-			if (file.length() != size)
-				return true;
-
 			// Git under windows only stores seconds so we round the timestamp
 			// Java gives us if it looks like the timestamp in index is seconds
 			// only. Otherwise we compare the timestamp at millisecond prevision.
-- 
GitLab