List of usage examples for org.eclipse.jgit.api BlameCommand setTextComparator
public BlameCommand setTextComparator(RawTextComparator textComparator)
From source file:org.eclipse.egit.ui.internal.blame.BlameOperation.java
License:Open Source License
public void execute(IProgressMonitor monitor) throws CoreException { final RevisionInformation info = new RevisionInformation(); info.setHoverControlCreator(new BlameInformationControlCreator(false)); info.setInformationPresenterControlCreator(new BlameInformationControlCreator(true)); final BlameCommand command = new BlameCommand(repository).setFollowFileRenames(true).setFilePath(path); if (startCommit != null) command.setStartCommit(startCommit); if (Activator.getDefault().getPreferenceStore().getBoolean(UIPreferences.BLAME_IGNORE_WHITESPACE)) command.setTextComparator(RawTextComparator.WS_IGNORE_ALL); BlameResult result;/*w w w. j a va 2 s .co m*/ try { result = command.call(); } catch (Exception e1) { Activator.error(e1.getMessage(), e1); return; } if (result == null) return; Map<RevCommit, BlameRevision> revisions = new HashMap<RevCommit, BlameRevision>(); int lineCount = result.getResultContents().size(); BlameRevision previous = null; for (int i = 0; i < lineCount; i++) { RevCommit commit = result.getSourceCommit(i); if (commit == null) { // Unregister the current revision if (previous != null) { previous.register(); previous = null; } continue; } BlameRevision revision = revisions.get(commit); if (revision == null) { revision = new BlameRevision(); revision.setRepository(repository); revision.setCommit(commit); revisions.put(commit, revision); info.addRevision(revision); } if (previous != null) if (previous == revision) previous.addLine(); else { previous.register(); previous = revision.reset(i); } else previous = revision.reset(i); } if (previous != null) previous.register(); shell.getDisplay().asyncExec(new Runnable() { public void run() { openEditor(info); } }); }
From source file:org.eclipse.orion.server.git.servlets.GitBlameHandlerV1.java
License:Open Source License
public void doBlame(Blame blame, Repository db) throws GitAPIException, IOException { String filePath = blame.getFilePath(); if (db != null && filePath != null) { BlameCommand blameCommand = new BlameCommand(db); blameCommand.setFilePath(filePath); blameCommand.setFollowFileRenames(true); blameCommand.setTextComparator(RawTextComparator.WS_IGNORE_ALL); if (blame.getStartCommit() != null) { blameCommand.setStartCommit(blame.getStartCommit()); }//w ww . j a v a 2 s . c om BlameResult result; try { result = blameCommand.call(); } catch (Exception e1) { return; } if (result != null) { blame.clearLines(); RevCommit commit; RevCommit prevCommit = null; String path; String prevPath = null; for (int i = 0; i < result.getResultContents().size(); i++) { try { commit = result.getSourceCommit(i); prevCommit = commit; } catch (NullPointerException e) { commit = prevCommit; } if (!blame.commitExists(commit)) { if (commit != null) { blame.addCommit(commit); } } try { path = commit.getId().getName(); prevPath = path; } catch (NullPointerException e) { path = prevPath; } blame.addLine(path); } } } }