AutoMerger: Catch RuntimeException from Merger#merge
AutoMerger: Catch RuntimeException from Merger#merge

Certain merge commits cannot be processed by JGit, in a way that throws
IllegalStateException:

Caused by: java.lang.IllegalStateException: Duplicate stages not allowed: 0 <filename>
        at org.eclipse.jgit.dircache.DirCacheBuilder.bad(DirCacheBuilder.java:277)
        at org.eclipse.jgit.dircache.DirCacheBuilder.resort(DirCacheBuilder.java:267)
        at org.eclipse.jgit.dircache.DirCacheBuilder.finish(DirCacheBuilder.java:223)
        at org.eclipse.jgit.merge.ResolveMerger.mergeTrees(ResolveMerger.java:1041)
        at org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(RecursiveMerger.java:200)
        at org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(RecursiveMerger.java:124)
        at org.eclipse.jgit.merge.ThreeWayMerger.mergeBase(ThreeWayMerger.java:133)
        at org.eclipse.jgit.merge.ResolveMerger.mergeImpl(ResolveMerger.java:304)
        at org.eclipse.jgit.merge.Merger.merge(Merger.java:212)
        at org.eclipse.jgit.merge.Merger.merge(Merger.java:165)
        at org.eclipse.jgit.merge.ThreeWayMerger.merge(ThreeWayMerger.java:114)
        at com.google.gerrit.server.patch.AutoMerger.merge(AutoMerger.java:116)
        at com.google.gerrit.server.patch.PatchListLoader.aFor(PatchListLoader.java:388)
        at com.google.gerrit.server.patch.PatchListLoader.readPatchList(PatchListLoader.java:154)
        at com.google.gerrit.server.patch.PatchListLoader.call(PatchListLoader.java:120)
        at com.google.gerrit.server.patch.PatchListLoader.call(PatchListLoader.java:74)

This codepath is called when indexing the change, which depends on the
PatchList. An unchecked exception bubbles up and fails the whole
request, which is a problem when this happens during ReceiveCommits, as
it effectively prevents pushing this change for review. As with other
types of exceptions during PatchListLoader, it's generally preferable to
continue with an incomplete PatchList that contains only the commit
message and merge list, rather than failing the whole operation.

Change-Id: Ib1cdb6ab1ca89e5bf20ae499c7501cc4e0087b85

qtproject/qtqa-gerrit,GerritCodeReview/gerrit,qtproject/qtqa-gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,qtproject/qtqa-gerrit,WANdisco/gerrit,GerritCodeReview/gerrit,WANdisco/gerrit,WANdisco/gerrit,qtproject/qtqa-gerrit,qtproject/qtqa-gerrit,WANdisco/gerrit,GerritCodeReview/gerrit,qtproject/qtqa-gerrit,WANdisco/gerrit,qtproject/qtqa-gerrit,WANdisco/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,WANdisco/gerrit