Bug 444363

Summary: DiffCommand: Doing "git diff HEAD" is too complicated
Product: [Technology] JGit Reporter: Robin Stocker <robin>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 Keywords: bugday, helpwanted
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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!