diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2011-03-22 11:19:18 +0100 |
---|---|---|
committer | Christian Halstrick <christian.halstrick@sap.com> | 2011-04-02 02:14:01 +0200 |
commit | ffbaf694e28fcc62c50326cd555d8f2646d31a0d (patch) | |
tree | 1b3211a45119581e2d5647512a19c98064e90b2c | |
parent | c261b28f677fdc755b86d16abebd2c30093514b4 (diff) | |
download | jgit-ffbaf694e28fcc62c50326cd555d8f2646d31a0d.tar.gz jgit-ffbaf694e28fcc62c50326cd555d8f2646d31a0d.zip |
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 <christian.halstrick@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java | 11 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java | 6 |
2 files changed, 17 insertions, 0 deletions
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 b2ccf2944a..33c3623058 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. + * <p> + * In case the RefDatabase implementation has internal caches this method + * will trigger that all these caches are cleared. + * <p> + * 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 8ac08efb83..c056d5a195 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 @@ -212,6 +212,12 @@ public class RefDirectory extends RefDatabase { } @Override + public void refresh() { + super.refresh(); + rescan(); + } + + @Override public boolean isNameConflicting(String name) throws IOException { RefList<Ref> packed = getPackedRefs(); RefList<LooseRef> loose = getLooseRefs(); |