|
|
@ -203,62 +203,63 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PullResult call() throws GitAPIException, |
|
|
|
public PullResult call() throws GitAPIException, |
|
|
|
WrongRepositoryStateException, InvalidConfigurationException, |
|
|
|
WrongRepositoryStateException, InvalidConfigurationException, |
|
|
|
DetachedHeadException, InvalidRemoteException, CanceledException, |
|
|
|
InvalidRemoteException, CanceledException, |
|
|
|
RefNotFoundException, RefNotAdvertisedException, NoHeadException, |
|
|
|
RefNotFoundException, RefNotAdvertisedException, NoHeadException, |
|
|
|
org.eclipse.jgit.api.errors.TransportException { |
|
|
|
org.eclipse.jgit.api.errors.TransportException { |
|
|
|
checkCallable(); |
|
|
|
checkCallable(); |
|
|
|
|
|
|
|
|
|
|
|
monitor.beginTask(JGitText.get().pullTaskName, 2); |
|
|
|
monitor.beginTask(JGitText.get().pullTaskName, 2); |
|
|
|
|
|
|
|
Config repoConfig = repo.getConfig(); |
|
|
|
|
|
|
|
|
|
|
|
String branchName; |
|
|
|
String branchName = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
String fullBranch = repo.getFullBranch(); |
|
|
|
String fullBranch = repo.getFullBranch(); |
|
|
|
if (fullBranch == null) |
|
|
|
if (fullBranch != null |
|
|
|
throw new NoHeadException( |
|
|
|
&& fullBranch.startsWith(Constants.R_HEADS)) { |
|
|
|
JGitText.get().pullOnRepoWithoutHEADCurrentlyNotSupported); |
|
|
|
|
|
|
|
if (!fullBranch.startsWith(Constants.R_HEADS)) { |
|
|
|
|
|
|
|
// we can not pull if HEAD is detached and branch is not
|
|
|
|
|
|
|
|
// specified explicitly
|
|
|
|
|
|
|
|
throw new DetachedHeadException(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
branchName = fullBranch.substring(Constants.R_HEADS.length()); |
|
|
|
branchName = fullBranch.substring(Constants.R_HEADS.length()); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
throw new JGitInternalException( |
|
|
|
throw new JGitInternalException( |
|
|
|
JGitText.get().exceptionCaughtDuringExecutionOfPullCommand, |
|
|
|
JGitText.get().exceptionCaughtDuringExecutionOfPullCommand, |
|
|
|
e); |
|
|
|
e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (remoteBranchName == null && branchName != null) { |
|
|
|
|
|
|
|
// get the name of the branch in the remote repository
|
|
|
|
|
|
|
|
// stored in configuration key branch.<branch name>.merge
|
|
|
|
|
|
|
|
remoteBranchName = repoConfig.getString( |
|
|
|
|
|
|
|
ConfigConstants.CONFIG_BRANCH_SECTION, branchName, |
|
|
|
|
|
|
|
ConfigConstants.CONFIG_KEY_MERGE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (remoteBranchName == null) { |
|
|
|
|
|
|
|
remoteBranchName = branchName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (remoteBranchName == null) { |
|
|
|
|
|
|
|
throw new NoHeadException( |
|
|
|
|
|
|
|
JGitText.get().cannotCheckoutFromUnbornBranch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!repo.getRepositoryState().equals(RepositoryState.SAFE)) |
|
|
|
if (!repo.getRepositoryState().equals(RepositoryState.SAFE)) |
|
|
|
throw new WrongRepositoryStateException(MessageFormat.format( |
|
|
|
throw new WrongRepositoryStateException(MessageFormat.format( |
|
|
|
JGitText.get().cannotPullOnARepoWithState, repo |
|
|
|
JGitText.get().cannotPullOnARepoWithState, repo |
|
|
|
.getRepositoryState().name())); |
|
|
|
.getRepositoryState().name())); |
|
|
|
|
|
|
|
|
|
|
|
Config repoConfig = repo.getConfig(); |
|
|
|
if (remote == null && branchName != null) { |
|
|
|
if (remote == null) { |
|
|
|
|
|
|
|
// get the configured remote for the currently checked out branch
|
|
|
|
// get the configured remote for the currently checked out branch
|
|
|
|
// stored in configuration key branch.<branch name>.remote
|
|
|
|
// stored in configuration key branch.<branch name>.remote
|
|
|
|
remote = repoConfig.getString( |
|
|
|
remote = repoConfig.getString( |
|
|
|
ConfigConstants.CONFIG_BRANCH_SECTION, branchName, |
|
|
|
ConfigConstants.CONFIG_BRANCH_SECTION, branchName, |
|
|
|
ConfigConstants.CONFIG_KEY_REMOTE); |
|
|
|
ConfigConstants.CONFIG_KEY_REMOTE); |
|
|
|
} |
|
|
|
} |
|
|
|
if (remote == null) |
|
|
|
if (remote == null) { |
|
|
|
// fall back to default remote
|
|
|
|
// fall back to default remote
|
|
|
|
remote = Constants.DEFAULT_REMOTE_NAME; |
|
|
|
remote = Constants.DEFAULT_REMOTE_NAME; |
|
|
|
|
|
|
|
} |
|
|
|
if (remoteBranchName == null) |
|
|
|
|
|
|
|
// get the name of the branch in the remote repository
|
|
|
|
|
|
|
|
// stored in configuration key branch.<branch name>.merge
|
|
|
|
|
|
|
|
remoteBranchName = repoConfig.getString( |
|
|
|
|
|
|
|
ConfigConstants.CONFIG_BRANCH_SECTION, branchName, |
|
|
|
|
|
|
|
ConfigConstants.CONFIG_KEY_MERGE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// determines whether rebase should be used after fetching
|
|
|
|
// determines whether rebase should be used after fetching
|
|
|
|
if (pullRebaseMode == null) { |
|
|
|
if (pullRebaseMode == null && branchName != null) { |
|
|
|
pullRebaseMode = getRebaseMode(branchName, repoConfig); |
|
|
|
pullRebaseMode = getRebaseMode(branchName, repoConfig); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (remoteBranchName == null) |
|
|
|
|
|
|
|
remoteBranchName = branchName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
|
|
|
|
final boolean isRemote = !remote.equals("."); //$NON-NLS-1$
|
|
|
|
String remoteUri; |
|
|
|
String remoteUri; |
|
|
|