From d00420ae6ec47419567493ee40b8cfa6525ad93d Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 20 Oct 2010 00:51:44 +0200 Subject: [PATCH] Make ObjectDirectory getPacks() work the first time If an object hasn't been accessed yet the pack list for a repository may not have been scanned from disk. If an application (e.g. the dumb transport servlet support code) asks for the pack list for an ObjectDirectory, we should load it immediately. Change-Id: I93d7b1bca422d905948e8e83b2afa83c8894a68b Signed-off-by: Shawn O. Pearce Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/storage/file/ObjectDirectory.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java index 86e19f4c5..77d2a3fc5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java @@ -217,7 +217,10 @@ public class ObjectDirectory extends FileObjectDatabase { * history of the repository. */ public Collection getPacks() { - final PackFile[] packs = packList.get().packs; + PackList list = packList.get(); + if (list == NO_PACKS) + list = scanPacks(list); + PackFile[] packs = list.packs; return Collections.unmodifiableCollection(Arrays.asList(packs)); }