/** * Peel back annotated tags until a non-tag object is found. * * @param obj * the starting object. * @return If {@code obj} is not an annotated tag, {@code obj}. Otherwise * the first non-tag object that {@code obj} references. The * returned object's headers have been parsed. * @throws org.eclipse.jgit.errors.MissingObjectException * a referenced object cannot be found. * @throws java.io.IOException * a pack file or loose object could not be read. */ public RevObject peel(RevObject obj) throws MissingObjectException, IOException { while (obj instanceof RevTag) { parseHeaders(obj); obj = ((RevTag) obj).getObject(); } parseHeaders(obj); return obj; }
private int minCommitTime() throws IOException { int min = Integer.MAX_VALUE; for (ObjectId id : revs) { RevObject o = walk.parseAny(id); while (o instanceof RevTag) { o = ((RevTag) o).getObject(); walk.parseHeaders(o); } if (o instanceof RevCommit) { RevCommit c = (RevCommit) o; if (c.getCommitTime() < min) min = c.getCommitTime(); } } return min; }
private void addRef(Ref ref, Map<ObjectId, String> nonCommits, FIFORevQueue pending) throws IOException { if (ref.getObjectId() == null) return; RevObject o = walk.parseAny(ref.getObjectId()); while (o instanceof RevTag) { RevTag t = (RevTag) o; nonCommits.put(o, ref.getName()); o = t.getObject(); walk.parseHeaders(o); } if (o instanceof NameRevCommit) { NameRevCommit c = (NameRevCommit) o; if (c.tip == null) c.tip = ref.getName(); pending.add(c); } else if (!nonCommits.containsKey(o)) nonCommits.put(o, ref.getName()); }
private RevCommit getParentCommit(RevCommit srcCommit, RevWalk revWalk) throws MultipleParentsNotAllowedException, MissingObjectException, IOException { final RevCommit srcParent; if (mainlineParentNumber == null) { if (srcCommit.getParentCount() != 1) throw new MultipleParentsNotAllowedException( MessageFormat.format( JGitText.get().canOnlyCherryPickCommitsWithOneParent, srcCommit.name(), Integer.valueOf(srcCommit.getParentCount()))); srcParent = srcCommit.getParent(0); } else { if (mainlineParentNumber.intValue() > srcCommit.getParentCount()) throw new JGitInternalException(MessageFormat.format( JGitText.get().commitDoesNotHaveGivenParent, srcCommit, mainlineParentNumber)); srcParent = srcCommit .getParent(mainlineParentNumber.intValue() - 1); } revWalk.parseHeaders(srcParent); return srcParent; }
private void pushLocalCommit(RevCommit p) throws MissingObjectException, IOException { if (p.has(LOCALLY_SEEN)) return; revWalk.parseHeaders(p); p.add(LOCALLY_SEEN); p.add(COMPLETE); p.carry(COMPLETE); localCommitQueue.add(p); }
/** * Locate a reference to any object and immediately parse its headers. * <p> * This method only returns successfully if the object exists and was parsed * without error. Parsing an object can be expensive as the type must be * determined. For blobs this may mean the blob content was unpacked * unnecessarily, and thrown away. * * @param id * name of the object. * @return reference to the object. Never null. * @throws org.eclipse.jgit.errors.MissingObjectException * the supplied does not exist. * @throws java.io.IOException * a pack file or loose object could not be read. */ @NonNull public RevObject parseAny(AnyObjectId id) throws MissingObjectException, IOException { RevObject r = objects.get(id); if (r == null) r = parseNew(id, reader.open(id)); else parseHeaders(r); return r; }
private void markLocalObjComplete(RevObject obj) throws IOException { while (obj.getType() == Constants.OBJ_TAG) { obj.add(COMPLETE); obj = ((RevTag) obj).getObject(); revWalk.parseHeaders(obj); } switch (obj.getType()) { case Constants.OBJ_BLOB: obj.add(COMPLETE); break; case Constants.OBJ_COMMIT: pushLocalCommit((RevCommit) obj); break; case Constants.OBJ_TREE: markTreeComplete((RevTree) obj); break; } }
else t = (RevTree) c; parseHeaders(t); return t;
if (obj.has(COMPLETE)) return; revWalk.parseHeaders(obj); } else { obj = revWalk.parseAny(id);
rw.parseHeaders(commit); rev = commit; --dist;
@Override public int compare(final Ref o1, final Ref o2) { final RevCommit revCommit1 = GitRepo.this.revWalk.lookupCommit(getPeeled(o1)); try { GitRepo.this.revWalk.parseHeaders(revCommit1); final RevCommit revCommit2 = GitRepo.this.revWalk.lookupCommit(getPeeled(o2)); GitRepo.this.revWalk.parseHeaders(revCommit2); return toGitCommit(revCommit1).compareTo(toGitCommit(revCommit2)); } catch (final Exception e) { throw propagate(e); } } }) //
walk.parseHeaders(c); c.add(DEEPEN_NOT); for (RevCommit p : c.getParents()) {
private boolean processOne(Candidate n) throws IOException { RevCommit parent = n.getParent(0); if (parent == null) return split(n.getNextCandidate(0), n); revPool.parseHeaders(parent); if (find(parent, n.sourcePath)) { if (idBuf.equals(n.sourceBlob)) return blameEntireRegionOnParent(n, parent); return splitBlameWithParent(n, parent); } if (n.sourceCommit == null) return result(n); DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath); if (r == null) return result(n); if (0 == r.getOldId().prefixCompare(n.sourceBlob)) { // A 100% rename without any content change can also // skip directly to the parent. n.sourceCommit = parent; n.sourcePath = PathFilter.create(r.getOldPath()); push(n); return false; } Candidate next = n.create(getRepository(), parent, PathFilter.create(r.getOldPath())); next.sourceBlob = r.getOldId().toObjectId(); next.renameScore = r.getScore(); next.loadText(reader); return split(next, n); }
/** * Get the tree associated with the given commit. * * @param walk * @param commit * @return tree * @throws IOException */ protected static RevTree getTree(final RevWalk walk, final RevCommit commit) throws IOException { final RevTree tree = commit.getTree(); if (tree != null) return tree; walk.parseHeaders(commit); return commit.getTree(); }
revWalk.parseHeaders(srcCommit); dco = new DirCacheCheckout(repo, repo.lockDirCache(), srcCommit.getTree());
revWalk.parseHeaders(srcParent);
private int minCommitTime() throws IOException { int min = Integer.MAX_VALUE; for (ObjectId id : revs) { RevObject o = walk.parseAny(id); while (o instanceof RevTag) { o = ((RevTag) o).getObject(); walk.parseHeaders(o); } if (o instanceof RevCommit) { RevCommit c = (RevCommit) o; if (c.getCommitTime() < min) min = c.getCommitTime(); } } return min; }
private void pushLocalCommit(final RevCommit p) throws MissingObjectException, IOException { if (p.has(LOCALLY_SEEN)) return; revWalk.parseHeaders(p); p.add(LOCALLY_SEEN); p.add(COMPLETE); p.carry(COMPLETE); localCommitQueue.add(p); }
private void pushLocalCommit(RevCommit p) throws MissingObjectException, IOException { if (p.has(LOCALLY_SEEN)) return; revWalk.parseHeaders(p); p.add(LOCALLY_SEEN); p.add(COMPLETE); p.carry(COMPLETE); localCommitQueue.add(p); }
for (int pIdx = 0; pIdx < pCnt; pIdx++) { RevCommit parent = n.getParent(pIdx); revPool.parseHeaders(parent); if (!find(parent, n.sourcePath)) continue;