JGitText.get().missingConfigurationForKey, missingKey));
}
final boolean isRemote = !remote.equals(".");
String remoteUri;
FetchResult fetchRes;
if (isRemote) {
remoteUri = repoConfig.getString(
ConfigConstants.CONFIG_REMOTE_SECTION, remote,
ConfigConstants.CONFIG_KEY_URL);
if (remoteUri == null) {
String missingKey = ConfigConstants.CONFIG_REMOTE_SECTION + DOT
+ remote + DOT + ConfigConstants.CONFIG_KEY_URL;
throw new InvalidConfigurationException(MessageFormat.format(
JGitText.get().missingConfigurationForKey, missingKey));
}
if (monitor.isCancelled())
throw new CanceledException(MessageFormat.format(
JGitText.get().operationCanceled,
JGitText.get().pullTaskName));
FetchCommand fetch = new FetchCommand(repo);
fetch.setRemote(remote);
fetch.setProgressMonitor(monitor);
configure(fetch);
fetchRes = fetch.call();
} else {
// we can skip the fetch altogether
remoteUri = "local repository";
fetchRes = null;
}
monitor.update(1);
if (monitor.isCancelled())
throw new CanceledException(MessageFormat.format(
JGitText.get().operationCanceled,
JGitText.get().pullTaskName));
// we check the updates to see which of the updated branches
// corresponds
// to the remote branch name
AnyObjectId commitToMerge;
if (isRemote) {
Ref r = null;
if (fetchRes != null) {
r = fetchRes.getAdvertisedRef(remoteBranchName);
if (r == null)
r = fetchRes.getAdvertisedRef(Constants.R_HEADS
+ remoteBranchName);
}
if (r == null)
throw new JGitInternalException(MessageFormat.format(JGitText
.get().couldNotGetAdvertisedRef, remoteBranchName));