try (ObjectWalk ow = new ObjectWalk(db)) { if (baseObjects != null) { ow.sort(RevSort.TOPO); if (!baseObjects.isEmpty()) ow.sort(RevSort.BOUNDARY, true); if (cmd.getType() == ReceiveCommand.Type.DELETE) continue; ow.markStart(ow.parseAny(cmd.getNewId())); RevObject o = ow.parseAny(have); ow.markUninteresting(o); o = ow.peel(o); if (o instanceof RevCommit) o = ((RevCommit) o).getTree(); if (o instanceof RevTree) ow.markUninteresting(o); ProgressMonitor.UNKNOWN); RevCommit c; while ((c = ow.next()) != null) { checking.update(1); if (providedObjects != null // while ((o = ow.nextObject()) != null) { checking.update(1); if (o.has(RevFlag.UNINTERESTING))
o.flags |= UNINTERESTING; if (boundary) addObject(o); o = ((RevTag) o).getObject(); parseHeaders(o); super.markUninteresting((RevCommit) o); else if (o instanceof RevTree) markTreeUninteresting((RevTree) o); else o.flags |= UNINTERESTING; addObject(o);
/** * Set the object filter for this walker. This filter affects the objects * visited by {@link #nextObject()}. It does not affect the commits listed * by {@link #next()}. * <p> * If the filter returns false for an object, then that object is skipped * and objects reachable from it are not enqueued to be walked recursively. * This can be used to speed up the object walk by skipping subtrees that * are known to be uninteresting. * * @param newFilter * the new filter. If null the special * {@link org.eclipse.jgit.revwalk.filter.ObjectFilter#ALL} * filter will be used instead, as it matches every object. * @since 4.0 */ public void setObjectFilter(ObjectFilter newFilter) { assertNotStarted(); objectFilter = newFilter != null ? newFilter : ObjectFilter.ALL; }
private int updatePathBuf(TreeVisit tv) { if (tv == null) return 0; // If nameEnd == 0 this tree has not yet contributed an entry. // Update only for the parent, which if null will be empty. int nameEnd = tv.nameEnd; if (nameEnd == 0) return updatePathBuf(tv.parent); int ptr = tv.pathLen; if (ptr == 0) { ptr = updatePathBuf(tv.parent); if (ptr == pathBuf.length) growPathBuf(ptr); if (ptr != 0) pathBuf[ptr++] = '/'; tv.pathLen = ptr; } int namePtr = tv.namePtr; int nameLen = nameEnd - namePtr; int end = ptr + nameLen; while (pathBuf.length < end) growPathBuf(ptr); System.arraycopy(tv.buf, namePtr, pathBuf, ptr, nameLen); return end; }
private boolean askForIsComplete() throws TransportException { try { try (ObjectWalk ow = new ObjectWalk(transport.local)) { for (ObjectId want : askFor.keySet()) ow.markStart(ow.parseAny(want)); for (Ref ref : localRefs().values()) ow.markUninteresting(ow.parseAny(ref.getObjectId())); ow.checkConnectivity(); } return true; } catch (MissingObjectException e) { return false; } catch (IOException e) { throw new TransportException(JGitText.get().unableToCheckConnectivity, e); } }
IncorrectObjectTypeException, IOException { while (o instanceof RevTag) { addObject(o); o = ((RevTag) o).getObject(); parseHeaders(o); super.markStart((RevCommit) o); else addObject(o);
final RevFlag include = walker.newFlag("include"); //$NON-NLS-1$ final RevFlag added = walker.newFlag("added"); //$NON-NLS-1$ walker.carry(include); walker.sort(RevSort.COMMIT_TIME_DESC); } else { walker.sort(RevSort.TOPO); if (thin) walker.sort(RevSort.BOUNDARY, true); AsyncRevObjectQueue q = walker.parseAny(all, true); try { for (;;) { for (RevTag tag : wantTags) all.add(tag.getObject()); q = walker.parseAny(all, true); try { while (q.next() != null) { depthWalk.markUnshallow(walker.parseAny(id)); walker.markStart(obj); walker.markUninteresting(obj); Set<ObjectId> roots = new HashSet<>(); RevCommit c;
throws MissingObjectException, IncorrectObjectTypeException, IOException { walker.reset(); final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder(); try { if (!bitmapResult.contains(obj)) { walker.markStart(walker.parseAny(obj)); marked = true; walker.setRevFilter(new AddToBitmapFilter(bitmapResult)); } else { walker.setRevFilter( new AddUnseenToBitmapFilter(seen, bitmapResult)); walker.setObjectFilter(new BitmapObjectFilter(bitmapResult)); while (walker.next() != null) { while ((ro = walker.nextObject()) != null) { bitmapResult.addObject(ro, ro.getType()); pm.update(1);
ObjectWalk ow = new ObjectWalk(db); if (tips.length != 0) { for (RevObject o : tips) ow.markStart(ow.parseAny(o)); } else { for (Ref r : db.getAllRefs().values()) ow.markStart(ow.parseAny(r.getObjectId())); final RevCommit o = ow.next(); if (o == null) break; final RevObject o = ow.nextObject(); if (o == null) break;
ObjectWalk w = new ObjectWalk(repo); try { for (Ref cr : newRefs) { checkCancelled(); w.markStart(w.parseAny(cr.getObjectId())); w.markUninteresting(w.parseAny(lpr.getObjectId())); w.dispose(); ObjectWalk w = new ObjectWalk(repo); try { for (Ref ar : getAllRefs()) for (ObjectId id : listRefLogObjects(ar, lastRepackTime)) { checkCancelled(); w.markStart(w.parseAny(id)); w.markUninteresting(w.parseAny(lpr.getObjectId())); w.dispose();
/** * Remove all entries from a map which key is the id of an object referenced * by the given ObjectWalk * * @param id2File * @param w * @throws MissingObjectException * @throws IncorrectObjectTypeException * @throws IOException */ private void removeReferenced(Map<ObjectId, File> id2File, ObjectWalk w) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevObject ro = w.next(); while (ro != null) { checkCancelled(); if (id2File.remove(ro.getId()) != null && id2File.isEmpty()) { return; } ro = w.next(); } ro = w.nextObject(); while (ro != null) { checkCancelled(); if (id2File.remove(ro.getId()) != null && id2File.isEmpty()) { return; } ro = w.nextObject(); } }
try { if (!bitmapResult.contains(obj)) { walker.markStart(walker.parseAny(obj)); marked = true; walker.setRevFilter(new AddToBitmapFilter(bitmapResult)); } else { walker.setRevFilter( new AddUnseenToBitmapFilter(seen, bitmapResult)); while (walker.next() != null) { while ((ro = walker.nextObject()) != null) { bitmapResult.addObject(ro, ro.getType()); pm.update(1);
for (int ptr = tv.ptr; ptr < buf.length;) { int startPtr = ptr; ptr = findObjectId(buf, ptr); idBuffer.fromRaw(buf, ptr); ptr += ID_SZ; int mode = parseMode(buf, startPtr, ptr, tv); int flags; switch (mode >>> TYPE_SHIFT) { obj.flags = SEEN; objects.add(obj); return enterTree(obj); obj.flags = flags = obj.flags | SEEN; if ((flags & UNINTERESTING) == 0) return enterTree(obj); if (boundary) return enterTree(obj); continue; releaseTreeVisit(tv); tv = currVisit; if ((flags & UNINTERESTING) == 0 | boundary) { if (o instanceof RevTree) { tv = newTreeVisit(o); tv.parent = null; currVisit = tv;
private Set<LfsPointer> findObjectsToPush() throws IOException, MissingObjectException, IncorrectObjectTypeException { Set<LfsPointer> toPush = new TreeSet<>(); try (ObjectWalk walk = new ObjectWalk(getRepository())) { for (RemoteRefUpdate up : refs) { walk.setRewriteParents(false); excludeRemoteRefs(walk); walk.markStart(walk.parseCommit(up.getNewObjectId())); while (walk.next() != null) { // walk all commits to populate objects } findLfsPointers(toPush, walk); } } return toPush; }
/** * Create and return an {@link org.eclipse.jgit.revwalk.ObjectWalk} using * the same objects. * <p> * Prior to using this method, the caller must reset this RevWalk to clean * any flags that were used during the last traversal. * <p> * The returned ObjectWalk uses the same ObjectReader, internal object pool, * and free RevFlags. Once the ObjectWalk is created, this RevWalk should * not be used anymore. * * @return a new walk, using the exact same object pool. */ public ObjectWalk toObjectWalkWithSameObjects() { ObjectWalk ow = new ObjectWalk(reader); RevWalk rw = ow; rw.objects = objects; rw.freeFlags = freeFlags; return ow; }
/** * Mark an element which used to be shallow in the client, but which * should now be considered a full commit. Any ancestors of this commit * should be included in the walk, even if they are the ancestor of an * uninteresting commit. * * @param c * Commit to mark * @throws MissingObjectException * @throws IncorrectObjectTypeException * @throws IOException */ public void markUnshallow(RevObject c) throws MissingObjectException, IncorrectObjectTypeException, IOException { if (c instanceof RevCommit) c.add(UNSHALLOW); super.markStart(c); }
ow = new DepthWalk.ObjectWalk(reader, depth - 1); } else { ow = new ObjectWalk(reader); ow.assumeShallow(shallow); preparePack(countingMonitor, ow, want, have);
private void excludeRemoteRefs(ObjectWalk walk) throws IOException { RefDatabase refDatabase = getRepository().getRefDatabase(); List<Ref> remoteRefs = refDatabase.getRefsByPrefix(remote()); for (Ref r : remoteRefs) { ObjectId oid = r.getPeeledObjectId(); if (oid == null) { oid = r.getObjectId(); } if (oid == null) { // ignore (e.g. symbolic, ...) continue; } RevObject o = walk.parseAny(oid); if (o.getType() == Constants.OBJ_COMMIT || o.getType() == Constants.OBJ_TAG) { walk.markUninteresting(o); } } }
private static void findLfsPointers(Set<LfsPointer> toPush, ObjectWalk walk) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevObject obj; ObjectReader r = walk.getObjectReader(); while ((obj = walk.nextObject()) != null) { if (obj.getType() == Constants.OBJ_BLOB && getObjectSize(r, obj) < LfsPointer.SIZE_THRESHOLD) { LfsPointer ptr = loadLfsPointer(r, obj); if (ptr != null) { toPush.add(ptr); } } } }
protected int walkLoop() throws Exception { int n = 0; for (final RevCommit c : walk) { if (++n > maxCount && maxCount >= 0) break; show(c); } if (walk instanceof ObjectWalk) { final ObjectWalk ow = (ObjectWalk) walk; for (;;) { final RevObject obj = ow.nextObject(); if (obj == null) break; show(ow, obj); } } return n; }