/** * Mark a root commit (i.e., one whose depth should be considered 0.) * * @param c * Commit to mark * @throws IOException * @throws IncorrectObjectTypeException * @throws MissingObjectException */ public void markRoot(RevCommit c) throws MissingObjectException, IncorrectObjectTypeException, IOException { if (c instanceof Commit) ((Commit) c).depth = 0; super.markStart(c); }
/** * Mark commits to start graph traversal from. * * @param list * commits to start traversing from. The commits passed must be * from this same revision walker. * @throws org.eclipse.jgit.errors.MissingObjectException * one of the commits supplied is not available from the object * database. This usually indicates the supplied commit is * invalid, but the reference was constructed during an earlier * invocation to {@link #lookupCommit(AnyObjectId)}. * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * the object was not parsed yet and it was discovered during * parsing that it is not actually a commit. This usually * indicates the caller supplied a non-commit SHA-1 to * {@link #lookupCommit(AnyObjectId)}. * @throws java.io.IOException * a pack file or loose object could not be read. */ public void markStart(Collection<RevCommit> list) throws MissingObjectException, IncorrectObjectTypeException, IOException { for (RevCommit c : list) markStart(c); }
public List<RevCommit> findCommitsUntilSomeTag(Repository repo, RevCommit head, @Nonnull Map<ObjectId, List<String>> tagObjectIdToName) { try (RevWalk revWalk = new RevWalk(repo)) { revWalk.markStart(head); for (RevCommit commit : revWalk) { ObjectId objId = commit.getId(); if (tagObjectIdToName.size() > 0) { List<String> maybeList = tagObjectIdToName.get(objId); if (maybeList != null && maybeList.get(0) != null) { return Collections.singletonList(commit); } } } return Collections.emptyList(); } catch (Exception e) { throw new RuntimeException("Unable to find commits until some tag", e); } }
c.flags |= UNINTERESTING; carryFlagsImpl(c); markStart(c);
IOException { walk.reset(); walk.markStart(start); if (end != null) walk.markUninteresting(end);
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { // get a list of all known heads, tags, remotes, ... Collection<Ref> allRefs = repository.getAllRefs().values(); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk revWalk = new RevWalk( repository )) { for( Ref ref : allRefs ) { revWalk.markStart( revWalk.parseCommit( ref.getObjectId() )); } System.out.println("Walking all commits starting with " + allRefs.size() + " refs: " + allRefs); int count = 0; for( RevCommit commit : revWalk ) { System.out.println("Commit: " + commit); count++; } System.out.println("Had " + count + " commits"); } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { // get a list of all known heads, tags, remotes, ... Collection<Ref> allRefs = repository.getAllRefs().values(); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk revWalk = new RevWalk( repository )) { for( Ref ref : allRefs ) { revWalk.markStart( revWalk.parseCommit( ref.getObjectId() )); } System.out.println("Walking all commits starting with " + allRefs.size() + " refs: " + allRefs); int count = 0; for( RevCommit commit : revWalk ) { System.out.println("Commit: " + commit); count++; } System.out.println("Had " + count + " commits"); } } } }
revWalk.markStart(child);
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { Ref head = repository.exactRef("refs/heads/master"); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); System.out.println("Start-Commit: " + commit); System.out.println("Walking all commits starting at HEAD"); walk.markStart(commit); int count = 0; for (RevCommit rev : walk) { System.out.println("Commit: " + rev); count++; } System.out.println(count); walk.dispose(); } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { Ref head = repository.exactRef("refs/heads/master"); // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); System.out.println("Start-Commit: " + commit); System.out.println("Walking all commits starting at HEAD"); walk.markStart(commit); int count = 0; for (RevCommit rev : walk) { System.out.println("Commit: " + rev); count++; } System.out.println(count); walk.dispose(); } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { String from = "3408efc41a51555d488d30d8a91ea560c5e13311"; String to = "7228de6ebe2a3087118562414061af4e189624c0"; // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(repository.resolve(to)); System.out.println("Start-Commit: " + commit); System.out.println("Walking all commits starting at " + to + " until we find " + from); walk.markStart(commit); int count = 0; for (RevCommit rev : walk) { System.out.println("Commit: " + rev); count++; if(rev.getId().getName().equals(from)) { System.out.println("Found from, stopping walk"); break; } } System.out.println(count); walk.dispose(); } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { String from = "3408efc41a51555d488d30d8a91ea560c5e13311"; String to = "7228de6ebe2a3087118562414061af4e189624c0"; // a RevWalk allows to walk over commits based on some filtering that is defined try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(repository.resolve(to)); System.out.println("Start-Commit: " + commit); System.out.println("Walking all commits starting at " + to + " until we find " + from); walk.markStart(commit); int count = 0; for (RevCommit rev : walk) { System.out.println("Commit: " + rev); count++; if(rev.getId().getName().equals(from)) { System.out.println("Found from, stopping walk"); break; } } System.out.println(count); walk.dispose(); } } } }
private void negotiateBegin() throws IOException { walk.resetRetain(REACHABLE, ADVERTISED); walk.markStart(reachableCommits); walk.sort(RevSort.COMMIT_TIME_DESC); walk.setRevFilter(new RevFilter() { @Override public RevFilter clone() { return this; } @Override public boolean include(RevWalk walker, RevCommit c) { final boolean remoteKnowsIsCommon = c.has(COMMON); if (c.has(ADVERTISED)) { // Remote advertised this, and we have it, hence common. // Whether or not the remote knows that fact is tested // before we added the flag. If the remote doesn't know // we have to still send them this object. // c.add(COMMON); } return !remoteKnowsIsCommon; } @Override public boolean requiresCommitBody() { return false; } }); }
private void reduceObjects(List<ReceiveCommand> cmds, List<RevCommit> commits, Repository git, Set<ObjectId> newObjs) throws IOException { try (RevWalk rw = new RevWalk(git)) { rw.setRetainBody(false); for (ObjectId id : newObjs) { RevObject obj = rw.parseAny(id); if (obj instanceof RevCommit) { rw.markStart((RevCommit) obj); } else { stage(cmds, id); } } for (RevCommit c; (c = rw.next()) != null;) { commits.add(c); rw.markUninteresting(c); } } }
private LogCommand add(boolean include, AnyObjectId start) throws MissingObjectException, IncorrectObjectTypeException, JGitInternalException { checkCallable(); try { if (include) { walk.markStart(walk.lookupCommit(start)); startSpecified = true; } else walk.markUninteresting(walk.lookupCommit(start)); return this; } catch (MissingObjectException e) { throw e; } catch (IncorrectObjectTypeException e) { throw e; } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().exceptionOccurredDuringAddingOfOptionToALogCommand , start), e); } }
private boolean wantSatisfied(RevObject want) throws IOException { if (want.has(SATISFIED)) return true; walk.resetRetain(SAVE); walk.markStart((RevCommit) want); if (oldestTime != 0) walk.setRevFilter(CommitTimeRevFilter.after(oldestTime * 1000L)); for (;;) { final RevCommit c = walk.next(); if (c == null) break; if (c.has(PEER_HAS)) { addCommonBase(c); want.add(SATISFIED); return true; } } return false; }
@Override public void prepareGitToExtractMoreDetailedRepoInformation() throws GitCommitIdExecutionException { try { // more details parsed out bellow Ref evaluateOnCommitReference = git.findRef(evaluateOnCommit); ObjectId evaluateOnCommitResolvedObjectId = git.resolve(evaluateOnCommit); if ((evaluateOnCommitReference == null) && (evaluateOnCommitResolvedObjectId == null)) { throw new GitCommitIdExecutionException("Could not get " + evaluateOnCommit + " Ref, are you sure you have set the dotGitDirectory property of this plugin to a valid path?"); } revWalk = new RevWalk(git); ObjectId headObjectId; if (evaluateOnCommitReference != null) { headObjectId = evaluateOnCommitReference.getObjectId(); } else { headObjectId = evaluateOnCommitResolvedObjectId; } if (headObjectId == null) { throw new GitCommitIdExecutionException("Could not get " + evaluateOnCommit + " Ref, are you sure you have some commits in the dotGitDirectory?"); } evalCommit = revWalk.parseCommit(headObjectId); revWalk.markStart(evalCommit); } catch (Exception e) { throw new GitCommitIdExecutionException("Error", e); } }
walk.markStart(reachableCommits); walk.setRevFilter(CommitTimeRevFilter.after(maxWhen)); for (;;) {