private void seeAllParents(@Nonnull RevWalk revWalk, RevCommit child, @Nonnull Set<ObjectId> seen) throws IOException { Queue<RevCommit> q = new ArrayDeque<>(); q.add(child); while (q.size() > 0) { RevCommit commit = q.remove(); for (ObjectId oid : commit.getParents()) { if (seen.contains(oid)) { continue; } seen.add(oid); q.add(revWalk.parseCommit(oid)); } } }
@Override public final boolean include(RevWalk rw, RevCommit c) { if (!bitmap.contains(c)) { return true; } for (RevCommit p : c.getParents()) { p.add(SEEN); } return false; }
public static ArrayMemory valueOf(RevCommit value) { ArrayMemory memory = valueOf((RevObject) value); memory.refOfIndex("commitTime").assign(value.getCommitTime()); memory.refOfIndex("encoding").assign(value.getEncodingName()); memory.refOfIndex("shortMessage").assign(value.getShortMessage()); memory.refOfIndex("fullMessage").assign(value.getFullMessage()); ArrayMemory parents = new ArrayMemory(); for (RevCommit revCommit : value.getParents()) { parents.add(valueOf((RevObject)revCommit)); } memory.refOfIndex("parents").assign(parents); PersonIdent authorIdent = value.getAuthorIdent(); memory.refOfIndex("author").assign(authorIdent == null ? Memory.NULL : valueOf(authorIdent)); PersonIdent committerIdent = value.getCommitterIdent(); memory.refOfIndex("committer").assign(committerIdent == null ? Memory.NULL : valueOf(committerIdent)); return memory; }
for (ObjectId oid : commit.getParents()) { if (!seena.contains(oid)) { q.add(revWalk.parseCommit(oid));
private void processCommit(RevObject obj) throws TransportException { final RevCommit commit = (RevCommit) obj; markLocalCommitsComplete(commit.getCommitTime()); needs(commit.getTree()); for (RevCommit p : commit.getParents()) needs(p); obj.add(COMPLETE); }
/** {@inheritDoc} */ @Override public final boolean include(RevWalk walker, RevCommit cmit) { Bitmap visitedBitmap; if (bitmap.contains(cmit)) { // already included } else if ((visitedBitmap = bitmap.getBitmapIndex() .getBitmap(cmit)) != null) { bitmap.or(visitedBitmap); } else { bitmap.addObject(cmit, Constants.OBJ_COMMIT); return true; } for (RevCommit p : cmit.getParents()) { p.add(RevFlag.SEEN); } return false; }
if (c.hasAll(allFlags)) { for (RevCommit p : c.getParents()) p.add(RevFlag.SEEN); } else {
/** {@inheritDoc} */ @Override public final boolean include(RevWalk walker, RevCommit cmit) { Bitmap visitedBitmap; if (seen.contains(cmit) || bitmap.contains(cmit)) { // already seen or included } else if ((visitedBitmap = bitmap.getBitmapIndex() .getBitmap(cmit)) != null) { bitmap.or(visitedBitmap); } else { bitmap.addObject(cmit, Constants.OBJ_COMMIT); return true; } for (RevCommit p : cmit.getParents()) { p.add(RevFlag.SEEN); } return false; }
private void markLocalCommitsComplete(int until) throws TransportException { try { for (;;) { final RevCommit c = localCommitQueue.peek(); if (c == null || c.getCommitTime() < until) return; localCommitQueue.next(); markTreeComplete(c.getTree()); for (RevCommit p : c.getParents()) pushLocalCommit(p); } } catch (IOException err) { throw new TransportException(JGitText.get().localObjectsIncomplete, err); } }
private RevCommit tryFastForward(String headName, RevCommit oldCommit, RevCommit newCommit) throws IOException, GitAPIException { boolean tryRebase = false; for (RevCommit parentCommit : newCommit.getParents()) if (parentCommit.equals(oldCommit)) tryRebase = true;
private List<RevCommit> getParents() { List<RevCommit> parents = new ArrayList<>(); for (RevCommit parent: getCommit().getParents()) parents.add(parent); return parents; }
if (amend) { RevCommit previousCommit = rw.parseCommit(headId); for (RevCommit p : previousCommit.getParents()) parents.add(p.getId()); if (author == null)
@Override public final boolean include(RevWalk rw, RevCommit c) { if (!bitmap.contains(c)) { return true; } for (RevCommit p : c.getParents()) { p.add(SEEN); } return false; }
@Override public final boolean include(RevWalk rw, RevCommit c) { if (!bitmap.contains(c)) { return true; } for (RevCommit p : c.getParents()) { p.add(SEEN); } return false; }
public boolean matches(Pattern pattern, RevCommit commit) { for (RevCommit parent : commit.getParents()) if (matches(pattern, parent.name())) return true; return false; }
for (RevCommit p : c.getParents()) { queue.add(p);
/** * Resolves the (first) parent commit. */ private RevCommit resolveParentRevCommit(RevCommit revCommit) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevCommit parent = null; try (RevWalk walker = new RevWalk(repo)) { parent = walker.parseCommit(revCommit.getParents()[0].getId()); } return parent; }
private boolean parentOf(ObjectId targetHead, ObjectId parentHead) throws MissingObjectException, IncorrectObjectTypeException, IOException { RevCommit targetCommit = revWalk.parseCommit(targetHead); for (RevCommit parent : targetCommit.getParents()) { if (parent.getId().equals(parentHead)) return true; } // else not directly a parent of return false; }
private void processCommit(final RevObject obj) throws TransportException { final RevCommit commit = (RevCommit) obj; markLocalCommitsComplete(commit.getCommitTime()); needs(commit.getTree()); for (final RevCommit p : commit.getParents()) needs(p); obj.add(COMPLETE); }
@Test public void createCommit_theResultCommitShouldHaveTheInputParents() throws IOException { AnyObjectId[] expectedParents = new AnyObjectId[] {commitToMaster(), commitToMaster()}; writeSomethingToCache(); RevCommit commit = CommitUtils.createCommit(someCommitMessage(), cache, somePersonIdent(), somePersonIdent(), Arrays.asList(expectedParents), repo); assertArrayEquals(expectedParents, commit.getParents()); }