Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » How to get changed file info specific to a commit using JGit
icon5.gif  How to get changed file info specific to a commit using JGit [message #1059026] Thu, 16 May 2013 09:32 Go to next message
Akira Tsuchiya is currently offline Akira TsuchiyaFriend
Messages: 1
Registered: May 2013
Junior Member
Razz
I want to know how to get only changed files' information specific to a commit.
And how to get a changed file's unified diff.
Re: How to get changed file info specific to a commit using JGit [message #1059583 is a reply to message #1059026] Mon, 20 May 2013 15:20 Go to previous message
Chris Aniszczyk is currently offline Chris AniszczykFriend
Messages: 674
Registered: July 2009
Senior Member
You can use the DiffCommand. See the DiffCommandTest for some examples:
http://git.eclipse.org/c/jgit/jgit.git/tree/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DiffCommandTest.java

Something like this should work though:
ObjectId headId = repository.resolve("HEAD^{tree}");
ObjectId oldId = repository.resolve(commitSha + "^{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()
.setNewTree(newTreeIter)
.setOldTree(oldTreeIter)
.call();
Previous Topic:archive --remote with jgit?
Next Topic:how to solve conflicts
Goto Forum:
  


Current Time: Tue Apr 16 13:55:49 GMT 2024

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

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

Back to the top