JGitText.get().cannotPullOnARepoWithState, repo
.getRepositoryState().name()));
// get the configured remote for the currently checked out branch
// stored in configuration key branch.<branch name>.remote
Config repoConfig = repo.getConfig();
String remote = repoConfig.getString(
ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
ConfigConstants.CONFIG_KEY_REMOTE);
if (remote == null)
// fall back to default remote
remote = Constants.DEFAULT_REMOTE_NAME;
// get the name of the branch in the remote repository
// stored in configuration key branch.<branch name>.merge
String remoteBranchName = repoConfig.getString(
ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
ConfigConstants.CONFIG_KEY_MERGE);
// determines whether rebase should be used after fetching
boolean doRebase = false;
switch (pullRebaseMode) {
case REBASE:
doRebase = true;
break;
case NO_REBASE:
doRebase = false;
break;
case USE_CONFIG:
default:
// check if the branch is configured for pull-rebase
doRebase = repoConfig.getBoolean(
ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
ConfigConstants.CONFIG_KEY_REBASE, false);
break;
}
if (remoteBranchName == null) {
String missingKey = ConfigConstants.CONFIG_BRANCH_SECTION + DOT
+ branchName + DOT + ConfigConstants.CONFIG_KEY_MERGE;
throw new InvalidConfigurationException(MessageFormat.format(
JGitText.get().missingConfigurationForKey, missingKey));
}
final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
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;