diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java index b28519b16..538e69a17 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java @@ -68,7 +68,7 @@ boolean dirty() { } @Override - void markDirty() { + public void markDirty() { // Always dirty. } }; @@ -186,7 +186,16 @@ public DfsPackFile[] getPacks() throws IOException { return getPackList().packs; } - PackList getPackList() throws IOException { + /** + * Scan and list all available pack files in the repository. + * + * @return list of available packs, with some additional metadata. The + * returned array is shared with the implementation and must not be + * modified by the caller. + * @throws IOException + * the pack list cannot be initialized. + */ + public PackList getPackList() throws IOException { return scanPacks(NO_PACKS); } @@ -202,7 +211,18 @@ protected DfsRepository getRepository() { * implementation and must not be modified by the caller. */ public DfsPackFile[] getCurrentPacks() { - return packList.get().packs; + return getCurrentPackList().packs; + } + + /** + * List currently known pack files in the repository, without scanning. + * + * @return list of available packs, with some additional metadata. The + * returned array is shared with the implementation and must not be + * modified by the caller. + */ + public PackList getCurrentPackList() { + return packList.get(); } /** @@ -460,17 +480,6 @@ protected void clearCache() { packList.set(NO_PACKS); } - /** - * Mark object database as dirty. - *

- * Used when the caller knows that new data might have been written to the - * repository that could invalidate open readers, for example if refs are - * newly scanned. - */ - protected void markDirty() { - packList.get().markDirty(); - } - @Override public void close() { // PackList packs = packList.get(); @@ -481,17 +490,25 @@ public void close() { // p.close(); } - static abstract class PackList { + /** Snapshot of packs scanned in a single pass. */ + public static abstract class PackList { /** All known packs, sorted. */ - final DfsPackFile[] packs; + public final DfsPackFile[] packs; - PackList(final DfsPackFile[] packs) { + PackList(DfsPackFile[] packs) { this.packs = packs; } abstract boolean dirty(); - abstract void markDirty(); + /** + * Mark pack list as dirty. + *

+ * Used when the caller knows that new data might have been written to the + * repository that could invalidate open readers depending on this pack list, + * for example if refs are newly scanned. + */ + public abstract void markDirty(); } private static final class PackListImpl extends PackList { @@ -507,7 +524,7 @@ boolean dirty() { } @Override - void markDirty() { + public void markDirty() { dirty = true; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java index 5765399f6..2e1c90d3c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java @@ -310,7 +310,7 @@ protected RefCache scanAllRefs() throws IOException { } ids.sort(); sym.sort(); - objdb.markDirty(); + objdb.getCurrentPackList().markDirty(); return new RefCache(ids.toRefList(), sym.toRefList()); }