summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-01-06 11:54:08 -0800
committerShawn Pearce <spearce@spearce.org>2016-01-06 11:54:45 -0800
commitf0d634eed764f8ff228ece18c6960375e90e6958 (patch)
tree9cf9c3b396c2937c7716d7cedb1b859dfc0c7c57 /org.eclipse.jgit
parent4c574b39b40be466bfe7d6aaaa011bd5a2e9023b (diff)
downloadjgit-f0d634eed764f8ff228ece18c6960375e90e6958.tar.gz
jgit-f0d634eed764f8ff228ece18c6960375e90e6958.zip
DFS: Allow other RefDatabase implementations
Permit a DfsRepository implementation to use a different RefDatabase than DfsRefDatabase. Change-Id: Ia263285f547bde1943993cc994d0222185021a16
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRepository.java10
3 files changed, 13 insertions, 9 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
index bcc46c3553..bb51fc4ca7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
@@ -70,6 +70,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdSet;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.pack.PackConfig;
import org.eclipse.jgit.storage.pack.PackStatistics;
@@ -78,9 +79,7 @@ import org.eclipse.jgit.util.io.CountingOutputStream;
/** Repack and garbage collect a repository. */
public class DfsGarbageCollector {
private final DfsRepository repo;
-
- private final DfsRefDatabase refdb;
-
+ private final RefDatabase refdb;
private final DfsObjDatabase objdb;
private final List<DfsPackDescription> newPackDesc;
@@ -195,7 +194,7 @@ public class DfsGarbageCollector {
ctx = (DfsReader) objdb.newReader();
try {
- refdb.clearCache();
+ refdb.refresh();
objdb.clearCache();
refsBefore = refdb.getRefs(ALL);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
index a1035a1284..e5469f6b83 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
@@ -262,6 +262,11 @@ public abstract class DfsRefDatabase extends RefDatabase {
}
@Override
+ public void refresh() {
+ clearCache();
+ }
+
+ @Override
public void close() {
clearCache();
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRepository.java
index 0d5fd0f859..ef8845084b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRepository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRepository.java
@@ -79,9 +79,6 @@ public abstract class DfsRepository extends Repository {
@Override
public abstract DfsObjDatabase getObjectDatabase();
- @Override
- public abstract DfsRefDatabase getRefDatabase();
-
/** @return a description of this repository. */
public DfsRepositoryDescription getDescription() {
return description;
@@ -95,7 +92,10 @@ public abstract class DfsRepository extends Repository {
* the repository cannot be checked.
*/
public boolean exists() throws IOException {
- return getRefDatabase().exists();
+ if (getRefDatabase() instanceof DfsRefDatabase) {
+ return ((DfsRefDatabase) getRefDatabase()).exists();
+ }
+ return true;
}
@Override
@@ -117,7 +117,7 @@ public abstract class DfsRepository extends Repository {
@Override
public void scanForRepoChanges() throws IOException {
- getRefDatabase().clearCache();
+ getRefDatabase().refresh();
getObjectDatabase().clearCache();
}