Community
Participate
Working Groups
With bug 334766 fixed I wanted to start using the new command by taking the returned list of DiffEntries and passing it to DiffFormatter#format(List <? extends DiffEntry>)[1]. To my surprise, in some cases it failed with a MissingObjectException. After a quick investigation it turned out that DiffFormatter#format(List<DiffEntry>) cannot be used if #scan(AbstractTreeIterator, AbstractTreeIterator)[2] hasn't been called first. The reason for this is simple, the #scan method updates the pair of sources used access the old and new sides of a DiffEntry[3]. It doesn't happen if you create a DiffFormatter from the scratch, init it properly and then try to call the #format(List<DiffEntry>) method with a list returned by the DiffCommand. I can think of two solutions here: * fix the formatter so the #format method can be called in isolation * hide the method and enhance the DiffCommand so it returns formatted diffs [1] org.eclipse.jgit.diff.DiffFormatter.format(List<? extends DiffEntry>) [2] org.eclipse.jgit.diff.DiffFormatter.scan(AbstractTreeIterator, AbstractTreeIterator) [1] org.eclipse.jgit.diff.DiffFormatter.source
Created attachment 201707 [details] mylyn/context/zip
Implemented a third solution here: http://egit.eclipse.org/r/4036. The DiffCommand now accepts OutputStream to write line data, so DiffFormat#format(List<DiffEntry>) is no longer called in the command explicitly. The method has been also annotated with a warning that #scan should be called first.
Ping.
This has been fixed with acd8aee98ac851b0c091bc5c5ea53cb2eaabbad0 Available in JGit 1.3