Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » jgit diff from different revision
icon9.gif  jgit diff from different revision [message #901087] Thu, 09 August 2012 17:24 Go to next message
Giovanni Amati is currently offline Giovanni AmatiFriend
Messages: 1
Registered: August 2012
Junior Member
I have 1 git repository and 1 branch and use jgit from java code.
I want get diff betwen HEAD and a previous revision. I have find this code but don't work.

String oldHash = "3d32c595a740ab70006cd13247377c57bea8eb9a";

ObjectId headId = repository.resolve("HEAD^{tree}");
ObjectId oldId = repository.resolve(oldHash + "^{tree}");

ObjectReader reader = repository.newObjectReader();

CanonicalTreeParser oldTreeIter = new CanonicalTreeParser();
oldTreeIter.reset(reader, oldId);
CanonicalTreeParser newTreeIter = new CanonicalTreeParser();
 newTreeIter.reset(reader, headId);

List<DiffEntry> diffs= git.diff()

I want emulate this command:

git diff --name-only 3d32c595a740ab70006cd13247377c57bea8eb9a..HEAD


[Updated on: Thu, 09 August 2012 17:32]

Report message to a moderator

Re: jgit diff from different revision [message #902386 is a reply to message #901087] Fri, 17 August 2012 12:20 Go to previous message
Stefan Lay is currently offline Stefan LayFriend
Messages: 342
Registered: July 2009
Senior Member

what exactly does not work? I tried the snippet and got the expected result.

Previous Topic:Force modified eGIT version
Next Topic:diff across a rename boundary?
Goto Forum:

Current Time: Mon Jun 25 02:44:02 GMT 2018

Powered by FUDForum. Page generated in 0.01986 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top