final List<RemoteRefUpdate> result = new LinkedList<RemoteRefUpdate>();
final Collection<RefSpec> procRefs = expandPushWildcardsFor(db, specs);
for (final RefSpec spec : procRefs) {
String srcSpec = spec.getSource();
final Ref srcRef = db.getRef(srcSpec);
if (srcRef != null)
srcSpec = srcRef.getName();
String destSpec = spec.getDestination();
if (destSpec == null) {
// No destination (no-colon in ref-spec), DWIMery assumes src
//
destSpec = srcSpec;
}
if (srcRef != null && !destSpec.startsWith(Constants.R_REFS)) {
// Assume the same kind of ref at the destination, e.g.
// "refs/heads/foo:master", DWIMery assumes master is also
// under "refs/heads/".
//
final String n = srcRef.getName();
final int kindEnd = n.indexOf('/', Constants.R_REFS.length());
destSpec = n.substring(0, kindEnd + 1) + destSpec;
}
final boolean forceUpdate = spec.isForceUpdate();