import org.eclipse.jgit.revwalk.RevSort;
import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevTree;
+import org.eclipse.jgit.storage.file.PackIndex;
import org.eclipse.jgit.storage.file.PackIndexWriter;
import org.eclipse.jgit.util.BlockList;
import org.eclipse.jgit.util.TemporaryBuffer;
private Set<ObjectId> tagTargets = Collections.emptySet();
+ private PackIndex[] excludeInPacks;
+
+ private PackIndex excludeInPackLast;
+
private Deflater myDeflater;
private final ObjectReader reader;
return stats.totalObjects;
}
+ /**
+ * Add a pack index whose contents should be excluded from the result.
+ *
+ * @param idx
+ * objects in this index will not be in the output pack.
+ */
+ public void excludeObjects(PackIndex idx) {
+ if (excludeInPacks == null) {
+ excludeInPacks = new PackIndex[] { idx };
+ excludeInPackLast = idx;
+ } else {
+ int cnt = excludeInPacks.length;
+ PackIndex[] newList = new PackIndex[cnt + 1];
+ System.arraycopy(excludeInPacks, 0, newList, 0, cnt);
+ newList[cnt] = idx;
+ excludeInPacks = newList;
+ }
+ }
+
/**
* Prepare the list of objects to be written to the pack stream.
* <p>
if (writeMonitor == null)
writeMonitor = NullProgressMonitor.INSTANCE;
+ excludeInPacks = null;
+ excludeInPackLast = null;
+
boolean needSearchForReuse = reuseSupport != null && (
reuseDeltas
|| config.isReuseObjects()
BlockList<RevCommit> commits = new BlockList<RevCommit>();
RevCommit c;
while ((c = walker.next()) != null) {
+ if (exclude(c))
+ continue;
if (c.has(inCachedPack)) {
CachedPack pack = tipToPack.get(c);
if (includesAllTips(pack, include, walker)) {
while ((o = walker.nextObject()) != null) {
if (o.has(RevFlag.UNINTERESTING))
continue;
+ if (exclude(o))
+ continue;
int pathHash = walker.getPathHashCode();
byte[] pathBuf = walker.getPathBuffer();
while ((o = walker.nextObject()) != null) {
if (o.has(RevFlag.UNINTERESTING))
continue;
+ if (exclude(o))
+ continue;
addObject(o, walker.getPathHashCode());
countingMonitor.update(1);
}
*/
public void addObject(final RevObject object)
throws IncorrectObjectTypeException {
- addObject(object, 0);
+ if (!exclude(object))
+ addObject(object, 0);
}
private void addObject(final RevObject object, final int pathHashCode) {
objectsMap.add(otp);
}
+ private boolean exclude(AnyObjectId objectId) {
+ if (excludeInPacks == null)
+ return false;
+ if (excludeInPackLast.hasObject(objectId))
+ return true;
+ for (PackIndex idx : excludeInPacks) {
+ if (idx.hasObject(objectId)) {
+ excludeInPackLast = idx;
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Select an object representation for this writer.
* <p>