protected FetchResult fetch(Repository clonedRepo, URIish u)
throws URISyntaxException,
org.eclipse.jgit.api.errors.TransportException, IOException,
GitAPIException {
// create the remote config and save it
RemoteConfig config = new RemoteConfig(clonedRepo.getConfig(), remote);
config.addURI(u);
final String dst = (bare ? Constants.R_HEADS : Constants.R_REMOTES
+ config.getName() + "/") + "*"; //$NON-NLS-1$//$NON-NLS-2$
RefSpec refSpec = new RefSpec();
refSpec = refSpec.setForceUpdate(true);
refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst); //$NON-NLS-1$
config.addFetchRefSpec(refSpec);
config.update(clonedRepo.getConfig());
clonedRepo.getConfig().save();
// run the fetch command
FetchCommand command = new FetchCommand(clonedRepo);