List<Ref> branches = getBranches(selection, repo);
if (branches.isEmpty()) {
PlotCommit commit = (PlotCommit) selection
.getFirstElement();
wiz = new CreateBranchWizard(repo, commit.name());
} else {
// prefer to create new branch based on a remote tracking branch
Collections.sort(branches, new Comparator<Ref>() {
public int compare(Ref o1, Ref o2) {
String refName1 = o1.getName();
String refName2 = o2.getName();
if (refName1.startsWith(Constants.R_REMOTES)) {
if (refName2.startsWith(Constants.R_HEADS))
return -1;
else
return refName1.compareTo(refName2);
} else {
if (refName2.startsWith(Constants.R_REMOTES))
return 1;
else
return refName1.compareTo(refName2);
}
}
});
Ref branch = branches.get(0).getLeaf();
wiz = new CreateBranchWizard(repo, branch.getName());
}
WizardDialog dlg = new WizardDialog(
HandlerUtil.getActiveShellChecked(event), wiz);
dlg.setHelpAvailable(false);