/** * Gets the push RefSpecs from the given remote configuration. If none is defined, a default * refspec is returned with {@link #DEFAULT_REFSPEC_SOURCE} and {@link * #DEFAULT_REFSPEC_DESTINATION}. * * @param config the remote config to get the push specs from * @return the push specs to use for the given remote configuration. */ private static List<RefSpec> getPushRefSpecs(RemoteConfig config) { List<RefSpec> pushRefSpecs = new ArrayList<RefSpec>(); List<RefSpec> remoteConfigPushRefSpecs = config.getPushRefSpecs(); if (!remoteConfigPushRefSpecs.isEmpty()) { pushRefSpecs.addAll(remoteConfigPushRefSpecs); } else { // default is to push current HEAD to remote MASTER pushRefSpecs.add( new RefSpec() .setSource(DEFAULT_REFSPEC_SOURCE) .setDestination(DEFAULT_REFSPEC_DESTINATION)); } return pushRefSpecs; }