From ffbaf694e28fcc62c50326cd555d8f2646d31a0d Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Tue, 22 Mar 2011 11:19:18 +0100 Subject: [PATCH] Enhance RefDatabase with a refresh() method There should be a way to explictly refresh the refs cached in the RefDirectory. Since commit c261b28 (use of FileSnapshot) this is not needed anymore for storage in the filesystem. But for DHT based storage an explicit refresh may be needed. Change-Id: I7d30c3496c05e1fb6e9519f3af9f23c6adb93bf9 Signed-off-by: Christian Halstrick --- .../src/org/eclipse/jgit/lib/RefDatabase.java | 11 +++++++++++ .../org/eclipse/jgit/storage/file/RefDirectory.java | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java index b2ccf2944..33c362305 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java @@ -209,4 +209,15 @@ public abstract class RefDatabase { * the reference space or object space cannot be accessed. */ public abstract Ref peel(Ref ref) throws IOException; + + /** + * Triggers a refresh of all internal data structures. + *

+ * In case the RefDatabase implementation has internal caches this method + * will trigger that all these caches are cleared. + *

+ * Implementors should overwrite this method if they use any kind of caches. + */ + public void refresh() { + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java index 8ac08efb8..c056d5a19 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java @@ -211,6 +211,12 @@ public class RefDirectory extends RefDatabase { packedRefs.set(PackedRefList.NO_PACKED_REFS); } + @Override + public void refresh() { + super.refresh(); + rescan(); + } + @Override public boolean isNameConflicting(String name) throws IOException { RefList packed = getPackedRefs();