merger.setWorkingTreeIterator(new FileTreeIterator(repo));
if (merger.merge(headCommit, stashCommit)) {
DirCache dc = repo.lockDirCache();
DirCacheCheckout dco = new DirCacheCheckout(repo, headTree, dc, merger.getResultTreeId());
dco.setFailOnConflict(true);
dco.checkout(); // Ignoring failed deletes....
if (applyIndex) {
ResolveMerger ixMerger = (ResolveMerger) strategy.newMerger(repo, true);
ixMerger.setCommitNames(new String[] { "stashed HEAD", "HEAD", "stashed index" });
ixMerger.setBase(stashHeadCommit);
boolean ok = ixMerger.merge(headCommit, stashIndexCommit);