Example usage for org.eclipse.jgit.diff DiffFormatter setAbbreviationLength

List of usage examples for org.eclipse.jgit.diff DiffFormatter setAbbreviationLength

Introduction

In this page you can find the example usage for org.eclipse.jgit.diff DiffFormatter setAbbreviationLength.

Prototype

public void setAbbreviationLength(int count) 

Source Link

Document

Change the number of digits to show in an ObjectId.

Usage

From source file:org.review_board.ereviewboard.ui.wizard.DiffCreator.java

License:Open Source License

public byte[] createDiff(Set<ChangedFile> selectedFiles, File rootLocation, Git gitClient)
        throws IOException, GitAPIException {

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    List<DiffEntry> changes = new ArrayList<DiffEntry>(selectedFiles.size());

    for (ChangedFile changedFile : selectedFiles) {
        changes.add(changedFile.getDiffEntry());
    }/*from w ww.j ava 2  s  . c  om*/

    final int INDEX_LENGTH = 40;
    DiffFormatter diffFormatter = new DiffFormatter(outputStream);
    diffFormatter.setRepository(gitClient.getRepository());
    diffFormatter.setDiffComparator(RawTextComparator.WS_IGNORE_ALL);
    diffFormatter.setAbbreviationLength(INDEX_LENGTH);
    diffFormatter.setDetectRenames(true);

    diffFormatter.format(changes);
    diffFormatter.flush();

    return outputStream.toByteArray();
}