Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java
index cf4ec58936..45f382316a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/GC.java
@@ -70,6 +70,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
@@ -83,6 +84,7 @@ import org.eclipse.jgit.revwalk.ObjectWalk;
import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.pack.PackWriter;
+import org.eclipse.jgit.storage.pack.PackWriter.ObjectIdSet;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.TreeFilter;
import org.eclipse.jgit.util.FileUtils;
@@ -498,10 +500,10 @@ public class GC {
tagTargets.add(ref.getPeeledObjectId());
}
- List<PackIndex> excluded = new LinkedList<PackIndex>();
- for (PackFile f : repo.getObjectDatabase().getPacks())
+ List<ObjectIdSet> excluded = new LinkedList<ObjectIdSet>();
+ for (final PackFile f : repo.getObjectDatabase().getPacks())
if (f.shouldBeKept())
- excluded.add(f.getIndex());
+ excluded.add(objectIdSet(f.getIndex()));
tagTargets.addAll(allHeads);
nonHeads.addAll(indexObjects);
@@ -513,7 +515,7 @@ public class GC {
tagTargets, excluded);
if (heads != null) {
ret.add(heads);
- excluded.add(0, heads.getIndex());
+ excluded.add(0, objectIdSet(heads.getIndex()));
}
}
if (!nonHeads.isEmpty()) {
@@ -632,7 +634,7 @@ public class GC {
private PackFile writePack(Set<? extends ObjectId> want,
Set<? extends ObjectId> have, Set<ObjectId> tagTargets,
- List<PackIndex> excludeObjects) throws IOException {
+ List<ObjectIdSet> excludeObjects) throws IOException {
File tmpPack = null;
File tmpIdx = null;
PackWriter pw = new PackWriter(repo);
@@ -643,7 +645,7 @@ public class GC {
if (tagTargets != null)
pw.setTagTargets(tagTargets);
if (excludeObjects != null)
- for (PackIndex idx : excludeObjects)
+ for (ObjectIdSet idx : excludeObjects)
pw.excludeObjects(idx);
pw.preparePack(pm, want, have);
if (pw.getObjectCount() == 0)
@@ -855,4 +857,11 @@ public class GC {
expireAgeMillis = -1;
}
+ private static ObjectIdSet objectIdSet(final PackIndex idx) {
+ return new ObjectIdSet() {
+ public boolean contains(AnyObjectId objectId) {
+ return idx.hasObject(objectId);
+ }
+ };
+ }
}

Back to the top