Bug 444363 - DiffCommand: Doing "git diff HEAD" is too complicated
Summary: DiffCommand: Doing "git diff HEAD" is too complicated
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2014-09-17 09:46 EDT by Robin Stocker CLA
Modified: 2014-10-19 04:04 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Stocker CLA 2014-09-17 09:46:52 EDT
DiffCommand has the following methods for controlling what should be compared:

  setOldTree(AbstractTreeIterator oldTree)
  setNewTree(AbstractTreeIterator newTree)

For doing a simple "git diff HEAD", the caller needs to do this to get oldTree:

  ObjectId head = repo.resolve(Constants.HEAD + "^{tree}");
  CanonicalTreeParser oldTree = new CanonicalTreeParser();
  ObjectReader reader = db.newObjectReader();
  try {
  	oldTree.reset(reader, head);
  } finally {
  	reader.release();
  }

Instead, we should have API that allows the caller to pass a String which we resolve to a tree, e.g. "HEAD", or "master".
Comment 1 Robin Stocker CLA 2014-10-19 04:04:15 EDT
This should be pretty simple to implement, added keywords. Patches welcome!