void () { boolean fatalErrorHappened = false; while (hasMoreRepositories() && !fatalErrorHappened) { final GitRepository repository = next(); GitSimpleEventDetector notFullyMergedDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.BRANCH_NOT_FULLY_MERGED); GitBranchNotMergedToUpstreamDetector notMergedToUpstreamDetector = new GitBranchNotMergedToUpstreamDetector(); GitCommandResult result = myGit.branchDelete(repository, myBranchName, false, notFullyMergedDetector, notMergedToUpstreamDetector); if (result.success()) { refresh(repository); markSuccessful(repository); } else if (notFullyMergedDetector.hasHappened()) { String baseBranch = notMergedToUpstreamDetector.getBaseBranch(); if (baseBranch == null) { // GitBranchNotMergedToUpstreamDetector didn't happen baseBranch = myCurrentHeads.get(repository); } myUnmergedToBranches.put(repository, new UnmergedBranchInfo(myDeletedBranchTips.get(repository), GitBranchUtil.stripRefsPrefix(baseBranch))); GitCommandResult forceDeleteResult = myGit.branchDelete(repository, myBranchName, true); if (forceDeleteResult.success()) { refresh(repository); markSuccessful(repository); } else { fatalError(getErrorTitle(), forceDeleteResult); fatalErrorHappened = true; } } else { fatalError(getErrorTitle(), result); fatalErrorHappened = true; } } if (!fatalErrorHappened) { notifySuccess(); } }