I'm trying to list all changes that occurred remotely without computing changes made in local. In this post its demonstrated how to do a diff against remote, like the code below:
git.fetch().call();
Repository repo = git.getRepository();
ObjectId fetchHead = repo.resolve("FETCH_HEAD^{tree}");
ObjectId head = repo.resolve("HEAD^{tree}");
ObjectReader reader = repo.newObjectReader();
CanonicalTreeParser oldTreeIter = new CanonicalTreeParser();
oldTreeIter.reset(reader, head);
CanonicalTreeParser newTreeIter = new CanonicalTreeParser();
newTreeIter.reset(reader, fetchHead);
List<DiffEntry> diffs= git.diff().setShowNameAndStatusOnly(true)
.setNewTree(newTreeIter)
.setOldTree(oldTreeIter)
.call();
for(DiffEntry entry : diffs) {
System.out.println(entry.toString());
}
The problem is that if we use a diff, local changes are computed as "reverse" remote changes. For example, if we add a file in local, it's computed as deleted from remote, since it doesn't exist there. In the same way, if I delete a file locally it's listed as a remote addition. How do you ignore this cases? Actually it's not exactly an issue of jgit, if you show me how to do using git commands I can find a way with jgit myself...
Edit: The triple dot is the solution in raw git, like this:
git diff --name-status HEAD...origin/master
Now I need to represent this command in JGit. Any suggestion?