use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class RepositoryCommit method getDiffs.
/**
* Get the changes between this commit and all parent commits
*
* @return non-null but possibly empty array of {@link FileDiff} instances.
*/
public FileDiff[] getDiffs() {
if (diffs == null) {
RevCommit[] parents = commit.getParents();
if (isStash() && commit.getParentCount() > 0)
parents = new RevCommit[] { commit.getParent(0) };
try (RevWalk revWalk = new RevWalk(repository);
TreeWalk treewalk = new TreeWalk(revWalk.getObjectReader())) {
treewalk.setRecursive(true);
treewalk.setFilter(TreeFilter.ANY_DIFF);
for (RevCommit parent : commit.getParents()) revWalk.parseBody(parent);
diffs = FileDiff.compute(repository, treewalk, commit, parents, TreeFilter.ALL);
} catch (IOException e) {
diffs = new FileDiff[0];
}
}
return diffs;
}
use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class StashEditorPage method getStagedDiffs.
/**
* @return diffs for staged changes
*/
protected FileDiff[] getStagedDiffs() {
List<FileDiff> stagedDiffsResult = new ArrayList<>();
if (getCommit().getRevCommit().getParentCount() > 1) {
RevCommit stagedCommit = getCommit().getRevCommit().getParent(PARENT_COMMIT_STAGED);
FileDiff[] stagedDiffs = new RepositoryCommit(getCommit().getRepository(), stagedCommit).getDiffs();
stagedDiffsResult.addAll(asList(stagedDiffs));
}
return stagedDiffsResult.toArray(new FileDiff[stagedDiffsResult.size()]);
}
Aggregations