JGitText.get().cannotDeleteCheckedOutBranch,
branchName));
RefUpdate update = repo.updateRef(fullName);
update.setRefLogMessage("branch deleted", false);
update.setForceUpdate(true);
Result deleteResult = update.delete();
boolean ok = true;
switch (deleteResult) {
case IO_FAILURE:
case LOCK_FAILURE:
case REJECTED:
ok = false;
break;
default:
break;
}
if (ok) {
result.add(fullName);
if (fullName.startsWith(Constants.R_HEADS)) {
String shortenedName = fullName
.substring(Constants.R_HEADS.length());
// remove upstream configuration if any
final StoredConfig cfg = repo.getConfig();
cfg.unsetSection(
ConfigConstants.CONFIG_BRANCH_SECTION,
shortenedName);
cfg.save();
}
} else
throw new JGitInternalException(MessageFormat.format(
JGitText.get().deleteBranchUnexpectedResult,
deleteResult.name()));
}
return result;
} catch (IOException ioe) {
throw new JGitInternalException(ioe.getMessage(), ioe);
}