From a770205070b52199e5c561f407ee0b0168dd8b9f Mon Sep 17 00:00:00 2001
From: "Shawn O. Pearce" <spearce@spearce.org>
Date: Fri, 16 Apr 2010 16:37:29 -0700
Subject: [PATCH] ReceivePack: Micro-optimize object lookup when checking
 connectivity

If we are checking the visibility of everything referenced in the
pack that isn't already reachable by a reference, it needs to be
in the provided set.  Since the provided set lists everything that
is in this pack, we can avoid checking to see if the blob exists
on disk, because we know it should be there, it was found in the
pack we just consumed.

Change-Id: Ie3c7746f734d13077242100a68e048f1ac18c34a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/eclipse/jgit/transport/ReceivePack.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
index 85522edc4..7c113d65f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -823,11 +823,15 @@ private void checkConnectivity() throws IOException {
 
 		RevObject o;
 		while ((o = ow.nextObject()) != null) {
+			if (ensureObjectsProvidedVisible) {
+				if (providedObjects.contains(o))
+					continue;
+				else
+					throw new MissingObjectException(o, o.getType());
+			}
+
 			if (o instanceof RevBlob && !db.hasObject(o))
 				throw new MissingObjectException(o, Constants.TYPE_BLOB);
-
-			if (ensureObjectsProvidedVisible && !providedObjects.contains(o))
-				throw new MissingObjectException(o, o.getType());
 		}
 	}
 
-- 
GitLab