if (this.ref != null) {
String branchName = Repository.shortenRefName(ref.getName());
BranchConfig branchConfig = new BranchConfig(
repository.getConfig(), branchName);
boolean alreadyConfigured = branchConfig.getMerge() != null;
UpstreamConfig config;
if (alreadyConfigured) {
boolean rebase = branchConfig.isRebase();
config = rebase ? UpstreamConfig.REBASE : UpstreamConfig.MERGE;
} else {
config = UpstreamConfig.getDefault(repository, Constants.R_REMOTES