I was facing the same problem and couldn't find a way to have the StashApplyCommand
tell me which files cause a conflict.
The workaround I currently use is to use a ResolveMerger
to see if the stash can be applied. If there are conflicting files, the merger is able to list them.
For example:
ObjectId headCommitId = // id of head commit
RevCommit stashCommit = // parsed stash (commit) to be applied
ObjectId stashHeadCommit = stashCommit.getParent(0);
ResolveMerger merger = (ResolveMerger)MergeStrategy.RESOLVE.newMerger(repository, true);
merger.setWorkingTreeIterator(new FileTreeIterator(repository));
merger.setBase(stashHeadCommit);
if(!merger.merge(headCommitId, stashCommit)) {
// look into merger.getFailingPaths() and merger.getUnmergedPaths()
}
Note that the above code snippet would not detect index conflicts as in my environment, the index can never cause conflicts. Though it should be possible to extend this approach to examine the index for conflicts. IIRC stashCommit.getParent( 1 )
points to the stashed index.
In the hope that the workaround becomes obsolete one day, I've filed an enhancement request:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=501475