I found something that worked for me.
Got most of this from a jgit cookbook: https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowFileDiff.java#start-of-content
The DiffEntry collection below shows me the modified files. (fyi, this can be done before a merge)
fetch();
// todo: isn't there a critical section here? Only within the same repo maybe. We could prevent simultaneous use of the same racfid.
Ref fetchHead;
try {
fetchHead = m_git.getRepository().findRef("FETCH_HEAD");
//todo: show the diff bewteen fetch-head and the current head.
// - get object id of fetch
// - get oid of head
ObjectId head = m_git.getRepository().resolve(Constants.HEAD);
AbstractTreeIterator oldTreeParser = prepareTreeParser(m_git.getRepository(), fetchHead.getObjectId());
AbstractTreeIterator newTreeParser = prepareTreeParser(m_git.getRepository(), head);
List<DiffEntry> diff = m_git.diff().
setOldTree(oldTreeParser).
setNewTree(newTreeParser).
// setPathFilter(PathFilter.create("README.md")).
// to filter on Suffix use the following instead
//setPathFilter(PathSuffixFilter.create(".java")).
call();
for (DiffEntry entry : diff) {
System.out.println("Entry: " + entry + ", from: " + entry.getOldId() + ", to: " + entry.getNewId());
}
}
private static AbstractTreeIterator prepareTreeParser(Repository repository, ObjectId objectId) throws IOException {
// from the commit we can build the tree which allows us to construct the TreeParser
//noinspection Duplicates
try (RevWalk walk = new RevWalk(repository)) {
RevCommit commit = walk.parseCommit(objectId);
RevTree tree = walk.parseTree(commit.getTree().getId());
CanonicalTreeParser treeParser = new CanonicalTreeParser();
try (ObjectReader reader = repository.newObjectReader()) {
treeParser.reset(reader, tree.getId());
}
walk.dispose();
return treeParser;
}
}