public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (PlotWalk revWalk = new PlotWalk(repository)) { ObjectId rootId = repository.resolve("refs/heads/master"); RevCommit root = revWalk.parseCommit(rootId); revWalk.markStart(root); PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<>(); plotCommitList.source(revWalk); plotCommitList.fillTo(Integer.MAX_VALUE); System.out.println("Printing children of commit " + root); for (RevCommit com : revWalk) { System.out.println("Child: " + com); } System.out.println("Printing with next()"); System.out.println("next: " + revWalk.next()); } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (PlotWalk revWalk = new PlotWalk(repository)) { ObjectId rootId = repository.resolve("refs/heads/master"); RevCommit root = revWalk.parseCommit(rootId); revWalk.markStart(root); PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<>(); plotCommitList.source(revWalk); plotCommitList.fillTo(Integer.MAX_VALUE); System.out.println("Printing children of commit " + root); for (RevCommit com : revWalk) { System.out.println("Child: " + com); } System.out.println("Printing with next()"); System.out.println("next: " + revWalk.next()); } } } }
final RevCommit rc = pw.parseCommit( oid ); toChangeSummary( rc ); pw.markStart( rc );
public ChangeSummary getHeadCommit( final File f ) throws GitSubsystemException { return lockAnd(me->{ try { final ObjectId oid = repo.resolve( "HEAD" ); final PlotWalk pw = new PlotWalk( repo ); final RevCommit rc = pw.parseCommit( oid ); pw.markStart( rc ); final String filepath = relativize( f ); pw.setTreeFilter( AndTreeFilter.create( PathFilter.create( filepath ), TreeFilter.ANY_DIFF ) ); final PlotCommitList<PlotLane> cl = new PlotCommitList<>(); cl.source( pw ); cl.fillTo( 1 ); final PlotCommit<PlotLane> commit = cl.get( 0 ); return toChangeSummary( commit ); } catch ( RevisionSyntaxException | IOException e ) { throw new GitSubsystemException( "Failed to resolve HEAD commit for: %s. Reason: %s", e, f, e.getMessage() ); } }); }
public void selectionChanged(final SelectionChangedEvent event) { final ISelection s = event.getSelection(); if (s.isEmpty() || !(s instanceof IStructuredSelection)) { commentViewer.setInput(null); fileViewer.setInput(null); return; } final IStructuredSelection sel = ((IStructuredSelection) s); if (sel.size() > 1) { commentViewer.setInput(null); fileViewer.setInput(null); return; } final PlotCommit<?> c = (PlotCommit<?>) sel.getFirstElement(); commentViewer.setInput(c); final PlotWalk walk = new PlotWalk(input.getRepository()); try { final RevCommit unfilteredCommit = walk.parseCommit(c); for (RevCommit parent : unfilteredCommit.getParents()) walk.parseBody(parent); fileViewer.setInput(unfilteredCommit); } catch (IOException e) { fileViewer.setInput(c); } finally { walk.dispose(); } } });