for (Ref ref : localRefs) {
String localRef = ref.getName();
String remoteRef = null;
boolean forceUpdate = false;
boolean delete = false;
refsToPush.add(new TransferableRef(localRef, remoteRef, forceUpdate, delete));
}
} else {
// push current branch
Ref currentBranch = resolveHeadTarget();
String localRef = currentBranch.getName();
String remoteRef = null;
boolean forceUpdate = false;
boolean delete = false;
refsToPush.add(new TransferableRef(localRef, remoteRef, forceUpdate, delete));
}
} else {
for (String refspec : refSpecsArg) {
String[] refs = refspec.split(":");
if (refs.length == 0) {
refs = new String[2];
refs[0] = resolveHeadTarget().getName();
refs[1] = null;
} else {
if (refs[0].startsWith("+")) {
refs[0] = refs[0].substring(1);
}
for (int i = 0; i < refs.length; i++) {
if (refs[i].trim().isEmpty()) {
refs[i] = null;
}
}
}
checkArgument(refs.length < 3,
"Invalid refspec, please use [+][<localref>][:][<remoteref>].");
boolean force = refspec.startsWith("+");
String localrefspec = refs[0];
boolean delete = localrefspec == null;
String remoterefspec = refs[refs.length == 2 ? 1 : 0];
refsToPush.add(new TransferableRef(localrefspec, remoterefspec, force, delete));
}
}
return refsToPush;
}